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

32 lines
1 KiB
YAML

---
- name: Combine postgresql_backup configuration
ansible.builtin.set_fact:
postgresql_backup: "{{ _postgresql_backup | combine(postgresql_backup, recursive=true) }}"
- name: Run optional versionscheck
ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck|bool
- name: Install required Packages
ansible.builtin.include_tasks: packages.yml
- name: Generate backup script
become: true
ansible.builtin.template:
src: templates/postgresql-backup-script.sh.j2
dest: /opt/postgresql-backup-script.sh
owner: "{{ postgresql_backup.user }}"
backup: true
mode: 0755
# TODO: Change to systemd timer!
- name: Add backup script as cronjob
become: true
ansible.builtin.cron:
name: backup postgres database
cron_file: 'wingcon_psql'
minute: "{{ postgresql_backup.cron_minute | default('*') }}"
hour: "{{ postgresql_backup.cron_hour | default('0') }}"
job: /opt/postgresql-backup-script.sh >/dev/null 2>&1
user: "{{ postgresql_backup.user }}"
when: postgresql_backup.cron