---

# setup local rsnapshot
#
# use vars from host:
# rsnapshot_local_dirs:
#  - /vol/shares/team/
#  - /vol/shares/qcs/
#  - /vol/shares/public/

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

- name: rsnapshot setup root dir
  tags: rsnapshot-local
  become: true
  ansible.builtin.file:
    dest: /vol/backup/rsnapshot_local
    state: directory

- name: setup rsnapshot config
  tags: rsnapshot-local
  become: true
  ansible.builtin.template:
    src: rsnapshot_perfact.conf.j2
    dest: /etc/rsnapshot_perfact.conf

- name: setup rsnapshot cronjob
  tags: rsnapshot-local
  become: true
  ansible.builtin.copy:
    content: |
      # this file is manages by ansible - do not edit manually
      #
      #
      # do local backups with rsnapshot
      15 6-20 * * *    root  rsnapshot -c /etc/rsnapshot_perfact.conf hourly
      38 1    * * *    root  rsnapshot -c /etc/rsnapshot_perfact.conf daily
      8  0    * * 7    root  rsnapshot -c /etc/rsnapshot_perfact.conf weekly
    dest: /etc/cron.d/rsnapshot-local
