a month ago
Hello - I'm trying to build an enhanced version of an app I deployed with Railway, and wanted to download a copy of the PostgreSQL database so I could see what the data currently looks like.
I've searched the forums here and it seems there isn't a straightforward way to do this, rather the response seems to be to run a sql dump command? My question is where do I run it to get a download?
Thanks
2 Replies
Status changed to Open Railway • about 1 month ago
a month ago
Hey, you need to execute the pg_dump command locally in your terminal with the connection details of your database (make sure to use the public url since you are connecting from the public). If I am not mistaken, another way would be to use the Railway CLI, SSH into your database and run pg_dump there.
a month ago
Run pg_dump from your own machine using the public database URL.
In the Postgres service, copy DATABASE_PUBLIC_URL (or the public host/user/password/db details), then locally run:
pg_dump "$DATABASE_PUBLIC_URL" --no-owner --no-acl -Fc -f railway-backup.dumpIf you prefer plain SQL:
pg_dump "$DATABASE_PUBLIC_URL" --no-owner --no-acl > railway-backup.sqlIf your laptop cannot connect, first check that public networking is enabled for the DB. Alternative path is a temporary Railway service with postgres client tools installed, but local pg_dump against the public URL is usually the cleanest way.