Created
August 18, 2021 10:23
-
-
Save benfavre/a4d39e7acca90a75d68474fbf611e43d to your computer and use it in GitHub Desktop.
Backup : Dump / Restore databases in seperate files MySQL, mysqldump
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
# DUMP | |
mysql -N -e 'show databases' | while read dbname; do mysqldump --complete-insert --routines --triggers --single-transaction "$dbname" > "$dbname".sql; done | |
# IMPORT | |
for sql in *.sql; do dbname=${sql/\.sql/}; echo -n "Now importing $dbname ... "; mysql $dbname < $sql; echo " done."; done | |
## Credits https://ma.ttias.be/mysql-back-up-take-a-mysqldump-with-each-database-in-its-own-sql-file/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment