# this local backup is completely independent from quadrant-backup-client and
# available on nearly all systems maintained by perfact

- name: install pfbackup
  tags: pfbackup
  become: true
  ansible.builtin.apt:
    name: pfbackup
    install_recommends: no
    state: present

- name: configure pfbackup
  tags: pfbackup
  become: true
  ansible.builtin.template:
    src:   etc/cron.d/perfact-backup-by-ansible
    dest: /etc/cron.d/perfact-backup-by-ansible

- name: configure dump_system.conf
  tags: pfbackup
  become: true
  ansible.builtin.template:
    src:   etc/dump_system.conf
    dest: /etc/perfact/backup/dump_system.conf

- name: setup directories needed for database backup
  tags: pfbackup
  become: true
  block:

    - name: create dirs to avoid error in pfbackup /vol/dbsync
      ansible.builtin.file:
        path: /vol/dbsync
        state: directory
        mode: '0755'

    - name: hint for dir dbsync
      ansible.builtin.copy:
        content: "dir must exist to avoid error in pfbackup\n"
        dest: "/vol/dbsync/dir_must_exist.txt"

    - name: create dirs to avoid error in pfbackup /vol/zope_files
      ansible.builtin.file:
        path: /vol/zope_files
        state: directory
        mode: '0755'

    - name: hint for dir zope_files
      ansible.builtin.copy:
        content: "dir must exist to avoid error in pfbackup\n"
        dest: "/vol/zope_files/dir_must_exist.txt"
