1
0
Fork 0
mirror of https://github.com/roles-ansible/role-postgresql-backup.git synced 2024-08-16 10:19:49 +02:00
role-postgresql-backup/tasks/main.yml

33 lines
1 KiB
YAML
Raw Normal View History

2020-07-08 14:01:03 +02:00
---
- name: Combine postgresql_backup configuration
ansible.builtin.set_fact:
postgresql_backup: "{{ _postgresql_backup | combine(postgresql_backup, recursive=true) }}"
2020-07-08 14:01:03 +02:00
- name: Run optional versionscheck
ansible.builtin.include_tasks: versioncheck.yml
2020-07-08 14:01:03 +02:00
when: submodules_versioncheck|bool
- name: Install required Packages
ansible.builtin.include_tasks: packages.yml
2020-07-08 17:22:41 +02:00
- name: Generate backup script
2020-07-08 17:22:41 +02:00
become: true
ansible.builtin.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
# TODO: Change to systemd timer!
- name: Add backup script as cronjob
2020-07-08 17:46:14 +02:00
become: true
ansible.builtin.cron:
2020-07-08 17:46:14 +02:00
name: backup postgres database
2022-01-31 18:56:17 +01:00
cron_file: 'wingcon_psql'
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