Version mysqldump

Posted for my own reference. Here’s a crontab entry that will gzip a mysqldump into a versioned filename:

10 */1 * * * mysqldump -uuser -ppassword --single-transaction database_name | gzip -9 --rsyncable > /home/backup/`/bin/date +\%Y-\%m-\%d_\%H:\%M`-database_name.sql.gz

Don’t forget to garbage collect that directory later. This will delete all files in the /home/backup/ directory older than 35 days:

0 0 * * * find /home/backup/ -type f -mtime +35 -exec rm -f {} \;


Comments are closed.