Possible Duplicate:
Suggestions for backing up php site and mysql db
Is there any php script that can do file system bac开发者_JAVA技巧kup and database backup (preferably zip them together) and send the backup to a remote server?
linux commands have better tools for this. you can access linux commands using the PHP exec() function. something like this:
// db
$db_backup_file = '/home/backup/db_'.date('Y-m-d').'.sql.gz';
$command = '/usr/bin/mysqldump -c -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASS.' --default-character-set=latin1 -N '.DB_NAME.' | gzip > '.$db_backup_file;
exec($command);
// file structure
$file_structure_backup_file = '/home/backup/files_'.date('Y-m-d').'.tar.gz';
$command = 'tar -zcf '.$file_structure_backup_file.' /home/';
exec($command);
you will want to check the linux command options, then test and tweak in a safe environment. you can then ftp or email the files to wherever. or you could put the same stuff in a cron job.
精彩评论