vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.29k stars 352 forks source link

How to install pgbackrest with init cluster ? #632

Closed karnain1803 closed 3 weeks ago

karnain1803 commented 3 weeks ago

Hi, what parameters should I change in order to simply install along with the pgbackrest cluster and it didn't fall into error? When I set pgbackrest_install: true, it waits for the command to restore the database from the backup, but I just need to install this along with the cluster.

karnain1803 commented 3 weeks ago

and for what in inventory file has pgbackrest:vars ?

vitabaks commented 3 weeks ago

what parameters should I change in order to simply install along with the pgbackrest cluster

patroni_cluster_bootstrap_method: "initdb"
patroni_create_replica_methods:
  - basebackup
pgbackrest_install: true

for what in inventory file has pgbackrest:vars ?

To configure the dedicated repository host (optional, if pgbackrest_install: true and "repo_host" is set).

karnain1803 commented 3 weeks ago

Thank you! why patroni_create_peplica_methods choosing on the basebackup, but no pgbackrest ? if pgbackrest too replica method for create ?

vitabaks commented 3 weeks ago

If I understood correctly, the first question was how to simply install pgbackrest package. If this is the case, pgbackrest_install: true and the default values for the rest of the variables are sufficient.

Everything else depends on the task you are currently solving, most variables can be redefined (if you know what you are doing).

karnain1803 commented 3 weeks ago

If I understood correctly, the first question was how to simply install pgbackrest package. If this is the case, pgbackrest_install: true and the default values for the rest of the variables are sufficient.

Everything else depends on the task you are currently solving, most variables can be redefined (if you know what you are doing).

Don't you think it's cool to add a playbook for backup using pgbackrest? In storage, on a remote server and locally?

vitabaks commented 3 weeks ago

Don't you think it's cool to add a playbook for backup using pgbackrest? In storage, on a remote server and locally?

This has already been implemented. See the pgbackrest variables.

karnain1803 commented 3 weeks ago

I want to restore the cluster by a certain time, when I log in to the master node, I can't do this, since I suppose I need to turn off the entire cluster? How could I do a proper database data recovery, and that the recovery would also be successful on replicas? What is my roadmap for proper database recovery in the cluster ?

vitabaks commented 3 weeks ago

Please see README https://github.com/vitabaks/postgresql_cluster?tab=readme-ov-file#restore-and-cloning

“Point-In-Time-Recovery” section.

karnain1803 commented 3 weeks ago

Yes, I looked at it. This is going to sound silly, but could you please clarify one thing for me. I have a backup on the host of the master node, when I make the setting that you specified for PITR, I get this. https://pastebin.com/JpY5GQHi That's why I'm asking, what's the right way to do it? I have a backup on the master node. There are no backups on the replicas, as provided by the fact that if, for example, only the master node is backed up, and for some reason there was no backup on the replicas, how should it recover?

for example, a backup from a replica is not being done, how do I transfer the backup from the master node to the replica? For some reason, I thought that by restoring to the master node, you would restore replicas because WAL

karnain1803 commented 3 weeks ago

I will correct the question, how to make a backup on all nodes at once?

vitabaks commented 3 weeks ago

Setting up backups locally is a bad idea, especially if it's a production cluster.

Use a dedicated backup server (pgbackrest_repo_host) or s3.

karnain1803 commented 3 weeks ago

Yes, you`re right. This is only test. Just i want to know "how to make a backup on all nodes at once" ? This is not provided in your playbook, except for the crone

vitabaks commented 3 weeks ago

This is an open source project, I use it personally and distribute it as is… \ I have plans to add more detailed documentation, I need to take more time for this.

You can also review the sponsorship program, which includes individual support.

karnain1803 commented 3 weeks ago

Thank you sir I have one last question. Is it meant to manually configure the user for dedicated host https://github.com/vitabaks/postgresql_cluster/blob/c12182611d6e610ce6b6d938ea813c4d2fbc4e3e/inventory#L61 Or is it enough for me to set pgbackrest_repo_host: "IP-Remote" without a user? Or I exhibit in vars/main.xml repo_host and repo_user and will such a user be created automatically?

vitabaks commented 3 weeks ago

Yes, you can redefine the values of these variables to suit your environment.