Prevent PostgreSQL from Running initdb on Existing Data Directory

francoleyesPRO

8 months ago

I'm facing an issue where PostgreSQL on Railway tries to run initdb on every deployment, despite the data directory (/var/lib/postgresql/data) already containing existing data. This results in the error:
initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
I need PostgreSQL to use the existing data without attempting to initialize again. How can I configure the service to avoid this issue?

Thank you.

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

7 Replies

8 months ago

Hello,

Can you help me to understand what you were trying to initially achieve with all the changes you have made to the database service?

At this time, it is severely misconfigured.

You may be able to get it to a working state -

- Remove the incorrect start command.

- Restore all variables to their original values.

Please note that we can't restore data unless the platform was at fault.


francoleyesPRO

8 months ago

I was trying to see how to connect from dbeaver to the database and when I couldn't I tried to do it from the “data” tab that asked me for extra variables to connect, I understand that I already returned the variables to their original values but it keeps trying to create a database.

Finally, can I transfer the data to create it in another database? Or to make some restoration?
I need to recover the data please


8 months ago

Do you know the original password that was used?


francoleyesPRO

8 months ago

Yes, I have the key that was there and I put it there as a variable but it still gives error


8 months ago

Then please restore ALL variables to their original values.


francoleyesPRO

8 months ago

All the variables I had are already there, I didn't change any variable from the one that comes in this template https://railway.app/template/m3dQ_V

I need to recover the information


8 months ago

You have 7 variable, the database from the template comes with 8.

Please restore all variables.