Setting up a daily cron job to mysqldump

Here is a a little life saver to dump a MySQL DB via cron and zip it up in date format

 0 2  * * * root mysqldump -u root -pPASSWORD databasename | gzip > /tmp/DBBACKUPS/database_`date ‘+%Y-%m-%d’`.sql.gz

This runs at 2am every morning. You can then set up another cron to delete old files or use logrotate to save you from running out of disk space.

eg

This command will remove any files over 30 days old:

find /path/to/files* -mtime +30 -exec rm {} \;