2020-07-08 14:01:03 +02:00
|
|
|
---
|
|
|
|
- name: combine postgresql_backup configuration
|
|
|
|
set_fact:
|
2020-07-09 16:33:35 +02:00
|
|
|
postgresql_backup: "{{ _postgresql_backup|combine(postgresql_backup, recursive=True) }}"
|
2020-07-08 14:01:03 +02:00
|
|
|
|
|
|
|
- include_tasks: versioncheck.yml
|
|
|
|
when: submodules_versioncheck|bool
|
|
|
|
|
2020-07-08 15:45:38 +02:00
|
|
|
- include_tasks: packages.yml
|
2020-07-08 17:22:41 +02:00
|
|
|
|
|
|
|
- name: generate backup script
|
|
|
|
become: true
|
|
|
|
template:
|
2020-07-21 18:31:14 +02:00
|
|
|
src: templates/postgresql-backup-script.sh.j2
|
2020-07-09 10:45:12 +02:00
|
|
|
dest: /opt/postgresql-backup-script.sh
|
2020-07-08 17:22:41 +02:00
|
|
|
owner: "{{ postgresql_backup.user }}"
|
|
|
|
backup: true
|
|
|
|
mode: 0755
|
2020-07-08 17:46:14 +02:00
|
|
|
|
|
|
|
- name: add backup script as cronjob
|
|
|
|
become: true
|
|
|
|
cron:
|
|
|
|
name: backup postgres database
|
|
|
|
cron_file: /etc/crontab
|
|
|
|
minute: "{{ postgresql_backup.cron_minute | default( '*' ) }}"
|
|
|
|
hour: "{{ postgresql_backup.cron_hour | default( '0' ) }}"
|
2020-07-09 10:53:26 +02:00
|
|
|
job: /opt/postgresql-backup-script.sh >/dev/null 2>&1
|
2020-07-08 17:46:14 +02:00
|
|
|
user: "{{ postgresql_backup.user }}"
|
2020-07-09 16:33:35 +02:00
|
|
|
when: postgresql_backup.cron
|