CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.93k stars 591 forks source link

How to create replicas #3763

Closed matzik12 closed 11 months ago

matzik12 commented 1 year ago

Hello, I am using pgo for a while and noticed that the replicas that i add to the patroni cluster are configured to be created using pgbasebackup. this is a problem for me because my standby was down and i had backup from standby only for a while. Now my cluster has no backup from last week and i want to create a new replica using pg_base_backup, but it doesnt work because the configuration of the "create_replica_method" in patroni.yml . this makes patroni use only pgbackrest to create a replica. Hope I have missed a feature and it already exists. please help me with this situation. Thank you! Ziv

andrewlecuyer commented 11 months ago

Hi @matzik12!

Once PGO has initialized a PostgresCluster it switches over to using pgBackRest for all replica creation (as you are seeing). This allows PGO to fully leverage the power of pgBackRest to cleanly and efficiently provision replicas.

In your scenario, it sounds like the correct/best approach is simply to create a new/fresh backup of your database (which is essentially what pg_basebackup would be doing anyway, only in this case the backup will be safely stored in the pgBackRest repo for further use as needed, rather than creating a backup solely to create a replica). Therefore, I recommend taking a fresh pgBackRest backup, and from there you can continue to cleanly/easily add new replicas.

Documentation for backups using PGO can be found here:

jmckulk commented 11 months ago

Hey @matzik12, were you able to get this working?

matzik12 commented 11 months ago

@jmckulk yes, like the comment above you said. Created new backup and initialized the replicas again. It worked. I asked it cause i didnt want to fix my backups but didnt find other option :(