Sep 13, 2018

How to backup MySQL with logrotate of mysqldump backups

Simply put something like this into /etc/logrotate.conf:

/var/backups/mysql/dump.sql {
daily
rotate 7
missingok
compress
postrotate
/usr/bin/mysqldump --defaults-extra-file=/.../backup-credentials.cnf --opt --flush-logs --all-databases > /var/backups/mysql/dump.sql
endscript
}