Forum Moderators: open
<?php
$dump_result = $rsync_result = false;
exec("mysqldump --user=[USER] --password=[PASS] --host=localhost --single-transaction --quick database_name > /backup/database_name_backup.sql", null, $dump_result);
if ($dump_result)
exec("rsync -a /backup username@remote_host:/backup", null, $rsync_result);
if ($rsync_result)
mail('hostmaster@example.com',
'MySQL Backup complete',
'Done');
else
mail('hostmaster@example.com',
'MySQL Backup failed',
'Uh oh');
?> No, I used to use WHM's backup tool until recently. Last time I ran it, the server load jumped to 50+, and the server was completely unresponsive until it timed out after 2 hours.
Creating backup
mysqldump -u root -p databasename > database.sql
mysqldump -u root -p [password] [DatabaseName] | gzip > [FileName]The slight downside is that you have to un-gzip the file when you restore, which may add a few seconds/minutes to the restore time.
--single-transaction --quick --lock-tables=false