Kind Urgent Request : need to reinstate the retired postgres service on our project clouddesk
sachi-on-cloud
PROOP

2 months ago

By mistake we have deleted the Postgres service of our project instead of just Redis.

Its a production database of one of our e-commerce application.

kindly requesting to help restore the same or help us with a data dump

Solved$20 Bounty

Pinned Solution

ilyass012
FREE

2 months ago

hey, i found your exact issue by reading the wrapper.sh and init-ssl.sh source code from the railwayapp-templates/postgres-ssl repo : https://github.com/railwayapp-templates/postgres-ssl/tree/main

wrapper.sh has a hard check that kills the process if the volume is not mounted at /var/lib/postgresql/data and if pgdata doesn't start with that same path. your old setup had volume at /data and pgdata at /data/pgdata which fails this check before postgres even starts, that's your real blocker.

the good news is wrapper.sh already handles your exact situation with this built-in logic , when postgresql.conf exists but server.crt is missing, it auto-generates the certs without touching your data.

so the fix is just two things:

  1. mount the volume at /var/lib/postgresql/data
  2. set pgdata to /var/lib/postgresql/data/pgdata

use the same postgres-ssl image you had before. wrapper.sh will detect your existing database, see the missing certs, generate them automatically and postgres will boot normally. your data is untouched.

6 Replies

sachi-on-cloud
PROOP

2 months ago

invalidated


sachi-on-cloud
PROOP

2 months ago

the volumes are still there..kindly help


2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 2 months ago


If volumes are still there, your data isn't deleted. You just need to create a new postgres service and attach the existing volume to it.


sachi-on-cloud
PROOP

2 months ago

thanks for the input. the issue is the the service discarded had railway template pg version 16 which had its pgdata @ /data/pgdata. now that template is not available. all the image defaults to /var/lib/postgres as pg data and variables are not respected. or am I missing something?

despite of setting pgdata to /data/pgdata and setting ssl-off in the conf, the log gives error as below

FATAL: could not load server certificate file "/var/lib/postgresql/data/certs/server.crt": No such file or directory


You can use postgres version 16 by changing the image last number in the postgres service settings

Attachments


sachi-on-cloud

thanks for the input. the issue is the the service discarded had railway template pg version 16 which had its pgdata @ /data/pgdata. now that template is not available. all the image defaults to /var/lib/postgres as pg data and variables are not respected. or am I missing something? despite of setting pgdata to /data/pgdata and setting ssl-off in the conf, the log gives error as below FATAL: could not load server certificate file "/var/lib/postgresql/data/certs/server.crt": No such file or directory

ilyass012
FREE

2 months ago

hey, i found your exact issue by reading the wrapper.sh and init-ssl.sh source code from the railwayapp-templates/postgres-ssl repo : https://github.com/railwayapp-templates/postgres-ssl/tree/main

wrapper.sh has a hard check that kills the process if the volume is not mounted at /var/lib/postgresql/data and if pgdata doesn't start with that same path. your old setup had volume at /data and pgdata at /data/pgdata which fails this check before postgres even starts, that's your real blocker.

the good news is wrapper.sh already handles your exact situation with this built-in logic , when postgresql.conf exists but server.crt is missing, it auto-generates the certs without touching your data.

so the fix is just two things:

  1. mount the volume at /var/lib/postgresql/data
  2. set pgdata to /var/lib/postgresql/data/pgdata

use the same postgres-ssl image you had before. wrapper.sh will detect your existing database, see the missing certs, generate them automatically and postgres will boot normally. your data is untouched.


Status changed to Solved chandrika 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...