Skip to content

Instantly share code, notes, and snippets.

@mupkoo
Last active October 24, 2022 09:26
Show Gist options
  • Select an option

  • Save mupkoo/8e7161113749ab8408c90c93e5219a42 to your computer and use it in GitHub Desktop.

Select an option

Save mupkoo/8e7161113749ab8408c90c93e5219a42 to your computer and use it in GitHub Desktop.
PostgreSQL and MySQL - Dump all databases into separate files
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