Created
November 15, 2016 11:39
-
-
Save RELATO/45f442452842314fae308cc4cb3631ee to your computer and use it in GitHub Desktop.
Script to export all databases to individual files with date + dbname
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 | |
USER="zend" | |
PASSWORD="" | |
#OUTPUT="/Users/rabino/DBs" | |
#rm "$OUTPUTDIR/*gz" > /dev/null 2>&1 | |
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 | |
# gzip $OUTPUT/`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