2020-07-08 14:01:03 +02:00
|
|
|
---
|
2023-03-02 16:21:16 +01: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
|
|
|
|
2023-03-02 16:21:16 +01:00
|
|
|
- name: Run optional versionscheck
|
|
|
|
ansible.builtin.include_tasks: versioncheck.yml
|
2020-07-08 14:01:03 +02:00
|
|
|
when: submodules_versioncheck|bool
|
|
|
|
|
2023-03-02 16:21:16 +01:00
|
|
|
- name: Install required Packages
|
|
|
|
ansible.builtin.include_tasks: packages.yml
|
2020-07-08 17:22:41 +02:00
|
|
|
|
2023-03-02 16:21:16 +01:00
|
|
|
- name: Generate backup script
|
2020-07-08 17:22:41 +02:00
|
|
|
become: true
|
2023-03-02 16:21:16 +01:00
|
|
|
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
|
|
|
|
2023-03-02 16:21:16 +01:00
|
|
|
# TODO: Change to systemd timer!
|
|
|
|
- name: Add backup script as cronjob
|
2020-07-08 17:46:14 +02:00
|
|
|
become: true
|
2023-03-02 16:21:16 +01:00
|
|
|
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'
|
2023-03-02 16:21:16 +01:00
|
|
|
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
|