Skip to content

Instantly share code, notes, and snippets.

@benfavre
Created August 18, 2021 10:23
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 benfavre/a4d39e7acca90a75d68474fbf611e43d to your computer and use it in GitHub Desktop.
Save benfavre/a4d39e7acca90a75d68474fbf611e43d to your computer and use it in GitHub Desktop.
Backup : Dump / Restore databases in seperate files MySQL, mysqldump
# 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