How to copy local postgres DB to

I’m evaluating deployment of my phx app. Is there an easy way to copy my local postgres db to my db?

Exact steps will depend on what you’ve done thus far or not.

Has the database been created within Postgres on your Fly Postgres app? If so, skip this step:

flyctl ssh console -a fly-postgres-app-name
createdb -p 5433 -U postgres server-db-name

Next, setup a proxy tunnel to the Fly Postgres app:

flyctl proxy 5433:5432 -a fly-postgres-app-name

In another terminal, dump your local database and restore it on the Fly Postgres app via the proxy:

pg_dump -O local-db-name | psql postgres://postgres@localhost:5433/server-db-name

If you’ve already setup another role within Postgres on your Fly Postgres app, you can use it instead of the postgres user: postgres://server-role-name@localhost:5433/server-db-name


Generally for specific questions you might want to try first

1 Like