Created
January 15, 2026 05:33
-
-
Save abhishekhugetech/04b4bf89780ee3000d75e17ba8744232 to your computer and use it in GitHub Desktop.
Gist to copy supabase DB to another DB
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
| docker run --name test_postgres -e POSTGRES_PASSWORD=123456 -p 5433:5432 -d postgres | |
| # returns container is as a018bf7d5e0a | |
| # We'll be using this container to run psql commands | |
| # docker exec -it a018bf7d5e0a psql | |
| # Dump roles and schema | |
| supabase db dump --db-url "postgresql://[USER]:[PASSWORD]@[HOST]:5432/postgres" -f roles.sql --role-only | |
| supabase db dump --db-url "postgresql://[USER]:[PASSWORD]@[HOST]:5432/postgres" -f schema.sql | |
| # Copy roles into container | |
| docker cp ./roles.sql a018bf7d5e0a:/roles.sql | |
| docker cp ./schema.sql a018bf7d5e0a:/schema.sql | |
| docker exec -it a018bf7d5e0a psql \ | |
| --single-transaction \ | |
| --variable ON_ERROR_STOP=1 \ | |
| --command 'SET session_replication_role = replica' \ | |
| --file roles.sql \ | |
| --file schema.sql \ | |
| --dbname "postgresql://[USER]:[PASSWORD]@[HOST]:6543/postgres" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment