Created
May 21, 2018 10:13
-
-
Save saadwaseem/d9521665895fbb0dce848008978432ea to your computer and use it in GitHub Desktop.
Export all 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 | |
USER="YOUR USER NAME" | |
PASSWORD="YOUR PASSWORD" | |
ExcludeDatabases="Database|information_schema|performance_schema|mysql" | |
databases=`mysql -u $USER -p $PASWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases` | |
for db in $databases; do | |
echo "Dumping database: $db" | |
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql | |
done |
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="YOUR USER NAME" | |
PASSWORD="YOUR PASSWORD" | |
FILES="/home/db_dumps/*" | |
for f in $FILES | |
do | |
echo "Processing $f file..." | |
mysql -u $USER -p$PASSWORD < $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment