Skip to content

Instantly share code, notes, and snippets.

@salaros
Created November 1, 2017 16:55
Show Gist options
  • Save salaros/aec1e6dc9a87f60bad739976bbdcd041 to your computer and use it in GitHub Desktop.
Save salaros/aec1e6dc9a87f60bad739976bbdcd041 to your computer and use it in GitHub Desktop.
# TODO use a dedicated backup user, protect gzip file with password etc
echo "/var/backups/all-databases.sql.gz {
daily
rotate 8
nocompress
create 640 root adm
postrotate
mysqldump -uroot --all-databases > /var/backups/all-databases.sql --single-transaction
gzip -9f /var/backups/all-databases.sql.sql
endscript
}" > /etc/logrotate.d/mysql-all-databases
touch /var/backups/all-databases.sql.gz
logrotate -f /etc/logrotate.d/mysql-all-databases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment