Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nicdnepr
Created June 27, 2017 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdnepr/cd96d4eea7cd3a884ab656745bb4ce20 to your computer and use it in GitHub Desktop.
Save nicdnepr/cd96d4eea7cd3a884ab656745bb4ce20 to your computer and use it in GitHub Desktop.
#!/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