Created
February 13, 2015 17:45
-
-
Save RomkeVdMeulen/a74abb55b1c246474a4b to your computer and use it in GitHub Desktop.
Logrotate backup instructions for a Dockerized mysql server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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