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

Syntax problem with cron wal-g command #658

Closed garry-t closed 3 months ago

garry-t commented 3 months ago

Fix syntax issue inside cron file #657 Plus fix problem with wal-g run, config file now specified in command directly.

This is a simplest solution I found. Minimum changes required, but now it works

vitabaks commented 3 months ago

@garry-t why not simplify the check for the same as for pgbackrest?

if [ $(psql -tAXc 'select pg_is_in_recovery()') = 'f' ]; then wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1; fi

or

[ $(psql -tAXc 'select pg_is_in_recovery()') = 'f' ] && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1

I don't see the need for different approaches.

garry-t commented 3 months ago

@garry-t why not simplify the check for the same as for pgbackrest?

if [ $(psql -tAXc 'select pg_is_in_recovery()') = 'f' ]; then wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1; fi

or

[ $(psql -tAXc 'select pg_is_in_recovery()') = 'f' ] && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1

I don't see the need for different approaches.

I kept solution closer to original. Will check your suggestion.

rrrru commented 2 months ago

Debian bookworm /bin/sh: 1: wal-g: not found

I think I should use the full path, like /usr/local/bin/wal-g

vitabaks commented 2 months ago

Feel free to suggest a PR.

rrrru commented 2 months ago

https://github.com/vitabaks/postgresql_cluster/pull/679