PG Dump and PG Migrate to a new deployment
kllymx
PROOP

5 months ago

Hi there,

Can anyone help walk me through how to essentially download all the data in my current postgres database (part of my n8n instance group). I want to redeploy n8n with a different template but first I want to get all the data I can (credentials, workflows etc) out of the instance, so I can then reupload it to the new instance and not have to manually reenter credentials or upload workflows.

Would really appreciate any help!

Solved$10 Bounty

11 Replies

Railway
BOT

5 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


vedmaka
HOBBY

5 months ago

As a side note: it seems the railway cli provides a shortcut for connecting to a database instance via railway connect[1] but this won't get you a dump. Would be great to have a shortcut for making database dump on the CLI


vedmaka
HOBBY

5 months ago

That said, I submitted a PR into the railway CLI repo adding the backup command https://github.com/railwayapp/cli/pull/678

(I am not a Rust coder so the PR likely requires improvements, but if eventually merged could be a nice shortcut for making database dumps)


vedmaka

That said, I submitted a PR into the railway CLI repo adding the backup command https://github.com/railwayapp/cli/pull/678(I am not a Rust coder so the PR likely requires improvements, but if eventually merged could be a nice shortcut for making database dumps)

5 months ago

That PR has been closed see here.


5 months ago

Hey kllymx!
Did what vedmaka suggest fix your issue?


5 months ago

In case you are still exploring options, I created this template with a migration tool.
https://railway.com/deploy/postgres-migrator?referralCode=crisog

You should use it with caution anyway and make sure you have backups before using it.

Depending on how technical you are, it might be safer than trying to do all of it manually.


kllymx
PROOP

5 months ago

Amazing, this worked thank you so much!


Status changed to Solved noahd 5 months ago


crisog

In case you are still exploring options, I created this template with a migration tool.https://railway.com/deploy/postgres-migrator?referralCode=crisogYou should use it with caution anyway and make sure you have backups before using it.Depending on how technical you are, it might be safer than trying to do all of it manually.

kllymx
PROOP

5 months ago

Oh this is great, will try it out. Thank you!


Status changed to Awaiting Railway Response Railway 5 months ago


kllymx

Oh this is great, will try it out. Thank you!

5 months ago

Let me know how it goes. My DMs are open if you are on the Discord server!


5 months ago

Hey, I just want to let you know that I have deleted your message due to the incorrect information given.

A database service should have a TCP proxy. Your instructions were on how to add an HTTP domain, and that simply will not work, as Postgres operates on TCP.


Status changed to Awaiting User Response Railway 5 months ago


brody

Hey, I just want to let you know that I have deleted your message due to the incorrect information given.A database service should have a TCP proxy. Your instructions were on how to add an HTTP domain, and that simply will not work, as Postgres operates on TCP.

vedmaka
HOBBY

5 months ago

You're right about the TCP. A shorter and a bit improved version of the originally proposed solution:

  1. For your database service ensure you have Public networking configured (TCP proxy)

  2. If it's not, on the Settings (Public Networking) click "+ TCP Proxy" and enter some port (i.e. 5432 ) and apply the changes

  3. Make sure you have pg_dump installed (see ie https://www.bytebase.com/reference/postgres/how-to/how-to-install-pgdump-on-mac-ubuntu-centos-windows/)

  4. Look at the database service Variables and find DATABASE_PUBLIC_URL

  5. Run pg_dump "<DATABASE_PUBLIC_URL>" -F c -f database.dump.sql where <DATABASE_PUBLIC_URL> must be replaced with your value of the variable

You can also use railway CLI to avoid looking up Railway dashboard for the database public URL. Just ensure that you're in a directory linked to the project and run:

pg_dump $(railway variables -s Postgres -k | awk -F= '/^DATABASE_PUBLIC_URL=/{print $2}') -F c -f test.dump.sql

(assuming your service name is Postgres)


Status changed to Awaiting Railway Response Railway 5 months ago


Status changed to Solved brody 5 months ago


Loading...