2 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!
11 Replies
2 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!
2 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
2 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)
2 months ago
That PR has been closed see here.
2 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.
vedmaka
@kllymx The simplest way would be to:Ensure that your Postgres database is reachable over public network (it is by default). If it's not - go to the settings and ensure that under Public Networking you have a generated domain set. If not - just click Generate Domain and apply the change.Go to the Postgres service Database tab and click "Connect" at the right top. Find connection string at the Public Network tabOnce you get the connection string that includes the username, the password, database name and the URL of your Postgres instance (the connection string looks likepostgresql://<username>:<password>@centerbeam.proxy.rlwy.net:49084/<database_name>) and the default database name is usually railwayYou can then use any client to make a dump of your database ( i.e. pgAdmin https://www.postgresql.org/download/ , HeidiSQL https://www.heidisql.com/ or similar ) by connecting to your database and dumping it into an SQL file that you can later upload the same way to another database instanceHere is the simplest way of making a dump using pg_dump CLI (that you'll get by installing pgAdmin):pg_dump "<CONNECTION_STRING_HERE>" -F p -f /path/where/to/save/dump.sqlp.s. if you're on Mac the simplest way to get the pg_dump utility is via Brewbrew install libpq that installs it into /opt/homebrew/opt/libpq/bin/pg_dump and on Linux even simpler by sudo apt install postgresql-client
2 months ago
Amazing, this worked thank you so much!
Status changed to Solved noahd • 2 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.
2 months ago
Oh this is great, will try it out. Thank you!
Status changed to Awaiting Railway Response Railway • 2 months ago
kllymx
Oh this is great, will try it out. Thank you!
2 months ago
Let me know how it goes. My DMs are open if you are on the Discord server!
vedmaka
@kllymx The simplest way would be to:Ensure that your Postgres database is reachable over public network (it is by default). If it's not - go to the settings and ensure that under Public Networking you have a generated domain set. If not - just click Generate Domain and apply the change.Go to the Postgres service Database tab and click "Connect" at the right top. Find connection string at the Public Network tabOnce you get the connection string that includes the username, the password, database name and the URL of your Postgres instance (the connection string looks likepostgresql://<username>:<password>@centerbeam.proxy.rlwy.net:49084/<database_name>) and the default database name is usually railwayYou can then use any client to make a dump of your database ( i.e. pgAdmin https://www.postgresql.org/download/ , HeidiSQL https://www.heidisql.com/ or similar ) by connecting to your database and dumping it into an SQL file that you can later upload the same way to another database instanceHere is the simplest way of making a dump using pg_dump CLI (that you'll get by installing pgAdmin):pg_dump "<CONNECTION_STRING_HERE>" -F p -f /path/where/to/save/dump.sqlp.s. if you're on Mac the simplest way to get the pg_dump utility is via Brewbrew install libpq that installs it into /opt/homebrew/opt/libpq/bin/pg_dump and on Linux even simpler by sudo apt install postgresql-client
2 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 • 2 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.
2 months ago
You're right about the TCP. A shorter and a bit improved version of the originally proposed solution:
For your database service ensure you have Public networking configured (TCP proxy)
If it's not, on the Settings (Public Networking) click "+ TCP Proxy" and enter some port (i.e.
5432) and apply the changesMake sure you have
pg_dumpinstalled (see ie https://www.bytebase.com/reference/postgres/how-to/how-to-install-pgdump-on-mac-ubuntu-centos-windows/)Look at the database service Variables and find
DATABASE_PUBLIC_URLRun
pg_dump "<DATABASE_PUBLIC_URL>" -F c -f database.dump.sqlwhere<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 • 2 months ago
Status changed to Solved brody • 2 months ago
