A cron job is a command that will run at a scheduled time. My website host allows me to set up cron jobs through the CPanel interface. Using a cron job I can automate MySQL database backups. Now a backup should always be placed on a different system to the one being backed up. I think a simple approach is to email myself the backup. So I use a cron job to backup my database. Its a series of piped commands.
mysqldump -e --user=username --password=password dbname | gzip | uuencode dbbackup_e.gz | mail firstname.lastname@example.org
Ok basically what this does is dump the database using mysqldump. This dump is a simple text file with a series of SQL commands that can used to restore the database using phpmyadmin. The option -e is used to create a dump with extended inserts which results in a smaller file. It is piped to gzip for compression and then uuencoded for transmission via email.
If the above command doesn’t work for you then you will need to install uuencode. If you have root access you can do so with the following command on CentOS or ask your hosting provider to do it for you:
yum install sharutils
I have set up this cron job to run once a week. So far it works beautifully!