CrunchyData / crunchy-containers

Containers for Managing PostgreSQL on Kubernetes by Crunchy Data
https://www.crunchydata.com/
Apache License 2.0
1.01k stars 328 forks source link

Restore postgres DB from backup #1402

Closed sumanth2893 closed 2 years ago

sumanth2893 commented 2 years ago

Describe the bug I was running crunchydb postgres on Kubernetes, and I was backing up the underlying pgdata volume using a tool called velero.

I am trying to use the raw volume data to spin up a postgres locally on my machine so I can run a pgdump, however I am finding very difficult to start the postgres using the underlying pddata.

I am trying to use the docker image https://hub.docker.com/r/crunchydata/crunchy-postgres and i am using below docker-compose and attach backup data in container.

version: "3.9"
services:
  postgres:
    image: crunchydata/crunchy-postgres:centos8-13.4-4.7.2
    environment: 
      PG_DATABASE: postgres
      PG_PRIMARY_PORT: 5432
      PG_MODE: primary
      MODE: postgres
      PG_USER: postgres
      PG_PASSWORD: postgres
      PG_PRIMARY_USER: postgres
      PG_PRIMARY_PASSWORD: postgres
      PG_ROOT_PASSWORD: postgres
      PGDATA_PATH_OVERRIDE: backup
      CRUNCHY_DEBUG: "TRUE"
    ports:
     - "5432:5432"
    volumes:
     - "./postgres:/pgdata/backup"

Output of this docker-compose

postgres container is not working

log

Thu Nov 11 15:48:53 UTC 2021 INFO: Image mode found: postgres
Thu Nov 11 15:48:53 UTC 2021 INFO: Starting in 'postgres' mode
Thu Nov 11 15:48:53 UTC 2021 INFO: Setting PGROOT to /usr/pgsql-13.
Thu Nov 11 15:48:53 UTC 2021 INFO: PG_CTL_START_TIMEOUT set at: 60
Thu Nov 11 15:48:53 UTC 2021 INFO: PG_CTL_STOP_TIMEOUT set at: 60
Thu Nov 11 15:48:53 UTC 2021 INFO: PG_CTL_PROMOTE_TIMEOUT set at: 60
Thu Nov 11 15:48:53 UTC 2021 INFO: Cleaning up the old postmaster.pid file..
Thu Nov 11 15:48:53 UTC 2021 INFO: User ID is set to uid=26(postgres) gid=26(postgres) groups=26(postgres).
Thu Nov 11 15:48:53 UTC 2021 INFO: Working on primary..
Thu Nov 11 15:48:53 UTC 2021 INFO: Initializing the primary database..
Thu Nov 11 15:48:53 UTC 2021 INFO: PGDATA already contains a database.
Thu Nov 11 15:48:53 UTC 2021 INFO: Setting ARCHIVE_MODE to off.
Thu Nov 11 15:48:53 UTC 2021 INFO: Setting ARCHIVE_TIMEOUT to 0.
Thu Nov 11 15:48:53 UTC 2021 INFO: Starting PostgreSQL..
2021-11-11 15:48:53.985 UTC [69] LOG:  pgaudit extension initialized
2021-11-11 15:48:53.986 UTC [69] WARNING:  pgnodemx: Kubernetes Downward API path /etc/podinfo does not exist: No such file or directory
2021-11-11 15:48:53.986 UTC [69] DETAIL:  disabling Kubernetes Downward API file system access
2021-11-11 15:48:53.996 UTC [69] LOG:  redirecting log output to logging collector process
2021-11-11 15:48:53.996 UTC [69] HINT:  Future log output will appear in directory "pg_log".
Thu Nov 11 15:48:54 UTC 2021 INFO: PostgreSQL is shutting down. Exiting..

what i am missing here ?

ref: https://github.com/CrunchyData/crunchy-containers/issues/1400

jkatz commented 2 years ago

A nearly identical situation is being discussed here: https://github.com/CrunchyData/crunchy-containers/issues/1400 Please add your comments there. Thanks!