Created
December 2, 2015 17:34
-
-
Save curiouscrusher/acd628d8e16fb73ee2d1 to your computer and use it in GitHub Desktop.
A quick shell script to dump all your databases and compress them.
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
USER="root" | |
PASSWORD="" | |
OUTPUT="/Users/yourusername/Sites" | |
ExcludeDatabases="Database|information_schema|performance_schema|mysql|sys" | |
databases=`mysql -u $USER -p$PASWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases` | |
for database in $databases; do | |
echo "Dumping database: $database" | |
mysqldump -u $USER -p$PASSWORD --databases $database > `date +%Y%m%d`.$database.sql | gzip $OUTPUT/`date +%Y%m%d`.$database.sql | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment