Clone existing Postgres DB
megadrive
PROOP

2 months 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

crisog
PRO

2 months ago

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 2 months ago


megadrive
PROOP

2 months ago

ill give it a go now and see how it goes


megadrive
PROOP

2 months ago

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


megadrive
PROOP

2 months 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


medim
MODERATOR

2 months ago

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


megadrive
PROOP

2 months ago

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


medim
MODERATOR

2 months 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


medim
MODERATOR

2 months ago

and as always, make sure you have backups


brody
EMPLOYEE

2 months ago

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


megadrive
PROOP

2 months ago

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


megadrive
PROOP

2 months ago

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


medim
MODERATOR

2 months ago

Yeah, u also need to wipe the volume


megadrive
PROOP

2 months ago

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


brody
EMPLOYEE

2 months ago

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


megadrive
PROOP

2 months ago

yeah i realised. ill give it a go!


megadrive
PROOP

2 months ago

thanks for all your help so far


medim
MODERATOR

2 months ago

Keep us updated <:salute:1137099685417451530>


Loading...