Here is a little PHP script that I use to backup MySQL databases on Hostgator Linux web servers. Simply save the .php file to a non publicly accessible part of the server and run regularly using crontab:

/usr/bin/php /home4/username/my-backups/site-name/backup-task.php

$FILE_NAME="site-name-backup-" . date("Y-m-d") . ".sql.gz";
exec('/usr/bin/mysqldump -u '.$DBUSER.' -p'.$DBPASSWD.' '.$DATABASE.' | gzip --best > '.$PATH.$FILE_NAME);
echo "Database(".$DATABASE.") backup completed. File name: ".$FILE_NAME;



No comments

Leave your comment

In reply to Some User
Captcha Image