Created
December 10, 2014 20:59
-
-
Save chulkilee/56f5c08ad5796258aec0 to your computer and use it in GitHub Desktop.
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
#!/bin/bash -eu | |
# Dump all mysql databases in to separate files | |
# config | |
user=backup-db | |
dir=/home/backup-db/data/mysql | |
# runtime variables | |
ts=$(date +%Y%m%d%H%M%S) | |
dbs=$(sudo -i -u ${user} mysql -N -r -s -e 'SHOW DATABASES' | egrep -v '^information_schema|performance_schema$') | |
sudo -u ${user} mkdir -p ${dir} | |
for db in ${dbs}; do | |
sudo -i -u ${user} sh -c "mysqldump -xQce --events $db | gzip > ${dir}/${db}.${ts}.sql.gz" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment