Importing an Immich DB backup into a new CNPG database
- Create the new Immich database
kubectl cnpg -n databases psql postgres-16 -- -c 'CREATE DATABASE immich;'
- Ensure that you're woring with the primary CNPG instance
kubectl cnpg -n databases status postgres-16 | grep "Primary instance:"
- Copy the database backup into the container's persistent storage (where there is likely enough room for it)
kubectl -n databases cp ./immich-db-backup.sql.gz postgres-16-2:/var/lib/postgresql/data/
- Exec into the postgres container
kubectl -n databases exec -it postgres-16-2 -- bash
- Run the Immich restore command
gunzip < "immich-db-backup-1735455600013.sql.gz"| sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | kubectl cnpg -n databases psql postgres-14 --