Last active
August 22, 2020 12:00
-
-
Save knzm/ca0088fc1b16f7c54f56c88ae5f6ca83 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/sh | |
set -eu | |
SELECT_SCHEMA_SQL=<<EOF | |
SELECT SCHEMA_NAME FROM information_schema.SCHEMATA | |
WHERE SCHEMA_NAME NOT IN ("information_schema", "performance_schema"); | |
EOF | |
mysql -u root -N -e "${SELECT_SCHEMA_SQL}" | while read dbname; do | |
echo "Dumping database $dbname" | |
time mysqldump -u root --single-transaction --databases $dbname | gzip -c >| "${dbname}.sql.gz"; | |
echo "Done." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment