Archive for October, 2006

MySQL Backup Script: Cron Hook

Tuesday, October 17th, 2006

Now let’s take that simple script below and automate it via cron.

To create a crontab:
type crontab -e then type in

MAILTO="yourmail@domain.com"
0 0 1,7,14,28 * * ~/scripts/mysqlbackup

then hit CTRL O to save then CTRL X to exit the editor

What does it mean? cron will run the mysqlbackup script on midnight every seven days of every month. If any error occurs then you’ll receive an email. If you want it to go to a log file just replace the above where appropriate with the code below:

0 0 1,7,14,28 * * ~/scripts/mysqlbackup > ~/logs/cron/cron.log

For a cron primer please refer to this site

MySQL Backup Script

Sunday, October 15th, 2006