Created
October 17, 2016 14:10
-
-
Save tperalta82/0fcf464ca96fa26d2c7c90bba551262d to your computer and use it in GitHub Desktop.
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 | |
DATABASES_TO_EXCLUDE="db1 db2 db3" | |
EXCLUSION_LIST="'information_schema','mysql','performance_schema'" | |
for DB in `echo "${DATABASES_TO_EXCLUDE}"` | |
do | |
EXCLUSION_LIST="${EXCLUSION_LIST},'${DB}'" | |
done | |
SQLSTMT="SELECT schema_name FROM information_schema.schemata" | |
SQLSTMT="${SQLSTMT} WHERE schema_name NOT IN (${EXCLUSION_LIST})" | |
MYSQLDUMP_DATABASES="--databases" | |
for DB in `mysql -uroot --pasdadasd -ANe"${SQLSTMT}"` | |
do | |
MYSQLDUMP_DATABASES="${MYSQLDUMP_DATABASES} ${DB}" | |
done | |
MYSQLDUMP_OPTIONS="--routines --triggers -uroot -pasdadasd" | |
mysqldump ${MYSQLDUMP_OPTIONS} ${MYSQLDUMP_DATABASES} > MySQLDatabases.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment