initdb: error: directory "/var/lib/postgresql/data/pgdata" exists but is not empty

127 Views Asked by At

I ended up with this logs in my postgres container running in kubernetes. How do I fix this?

The files belonging to this database system will be owned by user "postgres".

│ This user must also own the server process.

│ The database cluster will be initialized with locale "en_US.utf8".

│ The default database encoding has accordingly been set to "UTF8".

│ The default text search configuration will be set to "english".

│ Data page checksums are disabled.

│ initdb: error: directory "/var/lib/postgresql/data/pgdata" exists but is not empty

│ If you want to create a new database system, either remove or empty │

│ the directory "/var/lib/postgresql/data/pgdata" or run initdb

│ with an argument other than "/var/lib/postgresql/data/pgdata". ```

Here is variable and volumemount:

- name: PGDATA
  value: /var/lib/postgresql/data/pgdata
volumeMounts:
- mountPath: /var/lib/postgresql/data
  name: postgres-database

The pod is now crashed and I am trying to put in sleep and recover it. I do not want to loose any data

0

There are 0 best solutions below