Created
January 22, 2018 17:25
-
-
Save anthonybudd/b4020b80c4e28796df3ca8304a9bc18b to your computer and use it in GitHub Desktop.
Simple shell script to dump a whole MySQL instance to files
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 | |
USER="root" | |
PASSWORD="root" | |
OUTPUT="/Users/anthonybudd/sql/backup" | |
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database` | |
for db in $databases; do | |
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then | |
echo "Dumping database: $db" | |
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment