Skip to content

Instantly share code, notes, and snippets.

@RomkeVdMeulen
Created February 13, 2015 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomkeVdMeulen/a74abb55b1c246474a4b to your computer and use it in GitHub Desktop.
Save RomkeVdMeulen/a74abb55b1c246474a4b to your computer and use it in GitHub Desktop.
Logrotate backup instructions for a Dockerized mysql server.
# Logrotate backup instructions for a Dockerized mysql server.
# This will automatically dump all your databases once a day
# and maintain a compressed one week backlog.
# Write this config to /etc/logrotate.d/mysql-backup
/var/backups/db.sql.gz {
daily
rotate 8
nocompress
create 640 root adm
postrotate
docker run -i --link mysql:mysql --rm mariadb sh -c 'exec mysqldump -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" --all-databases --events' > /var/backups/db.sql
gzip -9f /var/backups/db.sql
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment