Backing up your database with a cron job on Bluehost

Posted on 23 March 2006

Bluehost provide a cron job set up interface in the control panel that makes it easy to set up cron jobs. The command I use is:


mysqldump -u DBUSERNAME --password=DBPASSWORD DBNAME

I've then set it up to run this once every day. All it does is email all the sql commands I would need to restore my database in the body of an email.

You don't have to run it every day and you could run other commands. For example you could run a php script that emailed your database to you as an attachment. The command would be something like this:

wget -q http://yourdomain.com/phpmysqlautobackup/run.php

Obviously it doesn't matter where the php file is located.

Got something to say?