Clone existing Postgres DB

megadrive
PROOP

a month ago

Is there a way to clone a Postgres DB from one environment to another? I want to test a new branch with existing data.

Solved$10 Bounty

0 Replies

I created this template to make it easier. Make sure to make a backup of the source DB before using it, and target DB must be clean.

https://railway.com/deploy/postgres-migrator


Status changed to Solved brody about 1 month ago


megadrive
PROOP

a month ago

ill give it a go now and see how it goes


megadrive
PROOP

a month ago

im having issues, but i dont think it has anything to do with your template


megadrive
PROOP

a month ago

i cant seem to add a Postgres 16 service, everytime i add a new one it installs 17 and my prod db is v16 according to the logs of the script


a month ago

You can always pg_dump and pg_restore, jus make sure you got backups in place before that.


megadrive
PROOP

a month ago

yeah i was thinking i might just have to go low-level


a month ago

**In that fresh DB instance, with no data: **
Go into the Service Settings -> Source Image -> Click the pen icon -> at the end of the image source replace 17 with 16.

It will crash because of the version diff, just wipe the attached volume and it will redeploy correctly.

1425617368599630000


a month ago

and as always, make sure you have backups


a month ago

I don't think Postgres can do a major version downgrade.


megadrive
PROOP

a month ago

yeah i did try that and it gave me some critical errors


megadrive
PROOP

a month ago

i could upgrade my prod db, really.. i have a recent backup


a month ago

Yeah, u also need to wipe the volume


megadrive
PROOP

a month ago

im trying to save my data <:kekw:788259314607325204>


a month ago

Medim is saying that in reference to the Postgres 17 service, not your original database.


megadrive
PROOP

a month ago

yeah i realised. ill give it a go!


megadrive
PROOP

a month ago

thanks for all your help so far


a month ago

Keep us updated <:salute:1137099685417451530>


Loading...
Clone existing Postgres DB - Railway Help Station