vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.48k stars 394 forks source link

Wal-g backup and restore command doenst work Ubuntu 22.04 due syntax issue #657

Closed garry-t closed 3 months ago

garry-t commented 3 months ago

It is not clear why it doesnt work. Problem seems like here '%{http_code}'. I see that it marked was tested in Ubuntu 22.04. Was wal-g also tested?

https://github.com/vitabaks/postgresql_cluster/blob/f59badf3513b3b7eac2ec4edfa11ff1ef72ac4ed/vars/main.yml#L483-L488 Tried with : /bin/bash /bin/sh No reason, same issue. syslog output CMD (sh -c 'curl -o /dev/null -s -w ")

vitabaks commented 3 months ago

Hi @garry-t

I will be grateful for PR if there is a mistake here and you manage to solve it.

I usually use pgbackrest and a simple check, for example:

if [ $(psql -tAXc 'select pg_is_in_recovery()') = 'f' ]; then pgbackrest --type=full --stanza={{ pgbackrest_stanza }} backup; fi
vitabaks commented 3 months ago

please attach the cron job file located in /etc/cron.d/walg

garry-t commented 3 months ago

Ok, understood.

cat /etc/cron.d/walg 
#Ansible: WAL-G: Create daily backup
30 3 * * * postgres  [ $(curl -s -o /dev/null -w '%{http_code}' http://IP:8008) = '200' ] && wal-g --config /var/lib/postgresql/.walg.json backup-push /var/lib/postgresql/15/main > /var/log/postgresql/walg_backup.log 2>&1
#Ansible: WAL-G: Delete old backups
30 6 * * * postgres  [ $(curl -s -o /dev/null -w '%{http_code}' http://IP:8008) = '200' ] && wal-g --config /var/lib/postgresql/.walg.json delete retain FULL 4 --confirm > /var/log/postgresql/walg_delete.log 2>&1

So I'll think how to solve it.