Last active
August 8, 2016 08:58
-
-
Save androzd/417c5cbaf0f7fe82ca193503d3e45473 to your computer and use it in GitHub Desktop.
Mysql Dump Rotation
This file contains hidden or 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
| /path/to/dumps/*.sql { | |
| daily | |
| rotate 14 | |
| missingok | |
| create 660 andrey andrey | |
| compress | |
| sharedscripts | |
| postrotate | |
| USER="dbuser" | |
| PASSWORD="dbpassword" | |
| OUTPUT="/path/to/dumps" | |
| databases=`mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database | grep -v _schema` | |
| for db in $databases; do | |
| mysqldump --user=$USER --password=$PASSWORD $db > $OUTPUT/$db.sql | |
| done | |
| mysqldump --user=$USER --password=$PASSWORD --all-databases > $OUTPUT/all.sql --single-transaction | |
| endscript | |
| } |
This file contains hidden or 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
| touch /path/to/dumps/empty.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment