Closed fatmaAliGamal closed 1 year ago
Thanks, I'll check it out
I'm not reproducing your problem
postgres@pgnode01:~$ sudo cat /var/log/syslog | grep "\[Cron\]" | grep "wal-g"
Jul 9 13:34:04 pgnode01 systemd[1]: Starting [Cron] "34 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g backup-push /var/lib/postgresql/15/main"...
Jul 9 13:34:06 pgnode01 systemd[1]: Finished [Cron] "34 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g backup-push /var/lib/postgresql/15/main".
Jul 9 13:37:22 pgnode01 systemd[1]: Starting [Cron] "37 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g delete before FIND_FULL $(date -d '-30 days' '+%FT%TZ') --confirm"...
Jul 9 13:37:23 pgnode01 systemd[1]: Finished [Cron] "37 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g delete before FIND_FULL $(date -d '-30 days' '+%FT%TZ') --confirm".
Jul 9 13:43:22 pgnode01 systemd[1]: Starting [Cron] "43 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g backup-push /var/lib/postgresql/15/main"...
Jul 9 13:43:24 pgnode01 systemd[1]: Finished [Cron] "43 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g backup-push /var/lib/postgresql/15/main".
Jul 9 13:45:17 pgnode01 systemd[1]: Starting [Cron] "45 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g delete before FIND_FULL $(date -d '-30 days' '+%FT%TZ') --confirm"...
Jul 9 13:45:18 pgnode01 systemd[1]: Finished [Cron] "45 13 * * * postgres [ $(curl -s -o /dev/null -w '%{http_code}' http://10.172.0.20:8008) = '200' ] && wal-g delete before FIND_FULL $(date -d '-30 days' '+%FT%TZ') --confirm".
postgres@pgnode01:~$
postgres@pgnode01:~$ wal-g backup-list
name modified wal_segment_backup_start
base_000000010000000000000007 2023-07-09T13:34:07Z 000000010000000000000007
base_000000010000000000000009 2023-07-09T13:43:25Z 000000010000000000000009
postgres@pgnode01:~$
check at Ubuntu 22.04 at ec2 i run with me when i write cron job /5 * root /etc/cron.d/script.sh {{ inventory_hostname }} {{ patroni_restapi_port }} {{ postgresql_data_dir }}
if [ "$(curl -s -o /dev/null -w '%{http_code}' http://$1:$2)" = "200" ]; then sudo -u postgres wal-g backup-push $3 fi
this is not the type of cron job that is offered by this automation, so you will have to figure it out yourself
wal_g_cron_jobs:
- name: "WAL-G: Create daily backup"
user: "postgres"
file: /etc/cron.d/walg
minute: "30"
hour: "3"
day: "*"
month: "*"
weekday: "*"
job: "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ] && wal-g backup-push {{ postgresql_data_dir }}"
I am closing this issue because the proposed command in the cron task works correctly. If you see the need to wrap a command in a script, please offer your PR.
Jul 9 10:04:24 ip-10-0-4-71 cron[73607]: (CRON) INFO (pidfile fd = 3) Jul 9 10:04:24 ip-10-0-4-71 cron[73607]: Error: bad username; while reading /etc/cron.d/walg Jul 9 10:04:24 ip-10-0-4-71 cron[73607]: (systemwalg) ERROR (Syntax error, this crontab file will be ignored) Jul 9 10:04:24 ip-10-0-4-71 cron[73607]: (CRON) INFO (Skipping @reboot jobs -- not system startup)