MySQL Backup Script: Cron Hook
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
October 18th, 2006 at 10:38 pm
you are such a flippin’ GEEK!
October 26th, 2006 at 6:49 pm
Use absolute paths in all your scripts they will save you many headaches at 3am.
#!/bin/sh
#assign
MY_UBER_SQL_BACKUPSCRIPT=/usr/local/scripts/mysqlbackup
#call
$MY_UBER_SQL_BACKUPSCRIT
And it is more secure.
-aC
October 30th, 2006 at 1:09 am
That’s why you’re on top of the hero list. Super X to the rescue. Thanks X, I’ll definitely keep that in mind the next time.