Last active
October 24, 2022 09:26
-
-
Save mupkoo/8e7161113749ab8408c90c93e5219a42 to your computer and use it in GitHub Desktop.
PostgreSQL and MySQL - Dump all databases into separate files
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
for db in (mysql -u root -e "SHOW DATABASES WHERE `Database` NOT LIKE '%test%'" -s --skip-column-names); | |
mysqldump -u root --single-transaction (string trim $db) > (string trim $db).dump; | |
end |
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
for db in (docker exec -i pg12 psql -U postgres -t -c "SELECT datname FROM pg_database WHERE datname NOT ILIKE '%_test%' AND datname NOT IN ('postgres', 'template0', 'template1')"); | |
docker exec -i pg12 pg_dump (string trim $db) -U postgres --no-owner --no-acl --clean --create --if-exists -F custom > (string trim $db).dump; | |
end | |
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
for db in (psql -t -c "SELECT datname FROM pg_database WHERE datname NOT ILIKE '%_test%'"); | |
pg_dump (string trim $db) --no-owner --no-acl --clean --create --if-exists -F custom > (string trim $db).dump; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment