Created
March 26, 2014 21:01
-
-
Save tonybolzan/9793414 to your computer and use it in GitHub Desktop.
Backup (mysqldump) all your MySQL databases in separate files
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
#!/bin/bash | |
# MySQL Dump All | |
# | |
# Backup (mysqldump) all your MySQL databases in separate files | |
# | |
# Author Tonin R. Bolzan <tonin@bolzan.io> | |
# License http://www.opensource.org/licenses/mit-license.php MIT License | |
# https://gist.github.com/tonybolzan | |
BACKUPFOLDER="/backup" | |
DATABASES=$(mysql --defaults-file=/etc/mysql/debian.cnf -Bse 'SHOW DATABASES WHERE `database` NOT IN ("information_schema", "performance_schema", "mysql", "test");') | |
DATE=$(date +"%y-%m-%d") | |
mkdir -p $BACKUPFOLDER | |
for DB in $DATABASES; do | |
mysqldump --defaults-file=/etc/mysql/debian.cnf -CER --triggers --add-drop-database --hex-blob --databases $DB | gzip > $BACKUPFOLDER/$DATE-$DB.sql.gz | |
# You can use Google Drive Uploader to send backups to your Google Account | |
# https://gist.github.com/tonybolzan/9792813 | |
# google_drive_upload.sh $BACKUPFOLDER/$DATE-$DB.sql.gz | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment