Skip to content

Commit

Permalink
Merge pull request #215 from chlordk/master
Browse files Browse the repository at this point in the history
Create crontab for pgbackrest
  • Loading branch information
vitabaks committed Nov 7, 2022
2 parents 23565bd + 3ff005b commit e23d43c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions roles/pgbackrest/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,19 @@
# - "'postgres_cluster' in group_names"
# tags: pgbackrest, pgbackrest_bootstrap_script

- name: Crontab pgbackrest
become: true
cron:
name: "{{ item.name | default('Backup') }}"
cron_file: /etc/cron.d/pgbackrest
job: "/usr/bin/pgbackrest --type={{ item.type }} --stanza={{ pgbackrest_stanza }} backup"
user: postgres
dow: "{{ item.dow }}"
hour: "{{ item.hour }}"
minute: "{{ item.minute }}"
ignore_errors: true
loop: "{{ pgbackrest_cron | flatten(1) }}"
when: pgbackrest_cron is defined and pgbackrest_cron | length > 0
tags: pgbackrest_cron

...
1 change: 1 addition & 0 deletions tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
- - pgbackrest_install
- - pgbackrest_conf
- - pgbackrest_ssh_keys
- - pgbackrest_cron
- netdata

3 changes: 3 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ pgbackrest_conf:
pgbackrest_patroni_cluster_restore_command:
'/usr/bin/pgbackrest --stanza={{ pgbackrest_stanza }} --delta restore' # restore from latest backup
# '/usr/bin/pgbackrest --stanza={{ pgbackrest_stanza }} --type=time "--target=2020-06-01 11:00:00+03" --delta restore' # Point-in-Time Recovery (example)
pgbackrest_cron: []
# - {name: "Full Backup", type: "full", hour: "06", minute: "30", dow: "0"}
# - {name: "Diff Backup", type: "diff", hour: "06", minute: "30", dow: "1-6"}

# PITR mode (if patroni_cluster_bootstrap_method: "pgbackrest" or "wal-g"):
# 1) The database cluster directory will be cleaned (for "wal-g") or overwritten (for "pgbackrest" --delta restore).
Expand Down

0 comments on commit e23d43c

Please sign in to comment.