ansible-role-postgresql/tasks/postgresql-backup.yml

49 lines
2.2 KiB
YAML
Raw Normal View History

2020-06-03 19:53:13 +02:00
---
- name: Backup script for the postgresql database(s)
2020-07-30 14:14:39 +02:00
template: src=postgresql-backup.sh.j2 dest=/usr/local/sbin/postgresql-backup owner=root mode=0744
2020-06-03 19:53:13 +02:00
tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ]
- name: daily cron job for the postgresql database(s) backup
copy: src=postgresql-backup.cron dest=/etc/cron.daily/postgresql-backup owner=root mode=0744
when: pgbackup_cron_step is undefined or
pgbackup_cron_step < 1 or
pgbackup_cron_step > 12
tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ]
- name: hour step cron job for the postgresql database(s) backup
cron:
name: "hourly step postgresql dump"
minute: "10"
hour: "*/{{ pgbackup_cron_step }}"
job: "/usr/local/sbin/postgresql-backup.cron"
when: pgbackup_cron_step is defined and
pgbackup_cron_step >=1 and
pgbackup_cron_step <= 12
tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ]
2020-07-30 14:14:39 +02:00
- name: postgresql backup defaults on deb/Ubuntu
template: src=pg_backup-default.j2 dest={{ pg_backup_conf_dir }}/pg_backup owner=root mode=0744
when: ansible_distribution_file_variety == "Debian"
tags: [ 'pg_backup', 'postgresql', 'postgres', 'pg_db' ]
- name: postgresql backup defaults on EL
template: src=pg_backup-default.j2 dest={{ pg_el_backup_conf_dir }}/pg_backup owner=root mode=0744
when: ansible_distribution_file_variety == "RedHat"
2020-06-03 19:53:13 +02:00
tags: [ 'pg_backup', 'postgresql', 'postgres', 'pg_db' ]
- name: Create the postgresql backups data directory
file: dest={{ pg_backup_destdir }} owner=postgres group=postgres mode=700 recurse=yes state=directory
tags: [ 'pg_backup', 'postgresql', 'postgres' ]
- name: Create the postgresql WAL files backup directories
file: dest={{ item }} owner=postgres group=postgres mode=700 recurse=yes state=directory
with_items:
- '{{ psql_wal_archiving_log_dir }}'
- '{{ psql_base_backup_dir }}'
when: psql_wal_files_archiving_enabled
tags: [ 'pg_backup', 'postgresql', 'postgres' ]
- name: authorization file for the psql command
template: src=pgpass.j2 dest={{ pg_backup_pass_file }} owner=root mode=0600
tags: [ 'pg_backup', 'postgresql', 'postgres', 'pgpass', 'pg_db' ]