Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- MYSQL_HOST=127.0.0.1
- MYSQL_USER=root
- MYSQL_PASS='123456'
- MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS}"
- #
- # Collect all database names except for
- # mysql, information_schema, and performance_schema
- #
- SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
- SQL="${SQL} ('mysql','information_schema','performance_schema')"
- DBLISTFILE=/tmp/DatabasesToDump.txt
- mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}
- DBLIST=""
- for DB in `cat ${DBLISTFILE}` ; do DBLIST="${DBLIST} ${DB}" ; done
- MYSQLDUMP_OPTIONS="--skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2"
- mysqldump ${MYSQL_CONN} ${MYSQLDUMP_OPTIONS} --databases ${DBLIST} > all-dbs.sql
Add Comment
Please, Sign In to add comment