--- - name: Set up borg cron job ansible.builtin.cron: name: 'Borgbackup' cron_file: borgbackup user: "{{ borg_user }}" hour: '{{ borg_cron.hour }}' minute: '{{ borg_cron.minute }}' day: "{{ borg_cron.day }}" weekday: "{{ borg_cron.weekday }}" month: "{{ borg_cron.month }}" job: > PATH=$PATH:/usr/local/bin nice -n {{ borg_cron_nice }} ionice -c {{ borg_cron_ionice }} borgmatic {{ borg_cron_action }} --log-file {{ borg_cron_log }} --log-file-verbosity 2 -c /etc/borgmatic/config.yaml >>{{ borg_cron_log }} 2>&1 when: borg_cron_enable - name: Set up borg prune cron job ansible.builtin.cron: name: 'Borgbackup Prune' cron_file: borgbackup user: "{{ borg_user }}" hour: >- {% if borg_cron.hour in range(0, 22) %} {{ '%02d' | format(borg_cron.hour + 2) }} {%- elif borg_cron.hour in [22, 23] -%} {% if borg_cron.hour == 22 %}0{% else %}1{% endif %} {%- endif -%} minute: '{{ borg_cron.minute }}' day: "{{ borg_cron.day }}" weekday: "{{ borg_cron.weekday }}" month: "{{ borg_cron.month }}" job: > PATH=$PATH:/usr/local/bin nice -n {{ borg_cron_nice }} ionice -c {{ borg_cron_ionice }} borgmatic prune --log-file {{ borg_cron_log }} --log-file-verbosity 2 -c /etc/borgmatic/config.yaml >>{{ borg_cron_log }} 2>&1 when: - borg_cron_enable - borg_cron_action != 'prune' - name: Create borg_cron_log file ansible.builtin.file: state: touch modification_time: preserve access_time: preserve path: '{{ borg_cron_log }}' owner: '{{ borg_user }}' group: '{{ borg_user }}' mode: '0600' when: borg_cron_enable - name: Copy s3-synchronize.sh scripts ansible.builtin.copy: src: files/s3-synchronize.sh dest: /usr/local/bin/s3-synchronize.sh mode: '0755' when: borg_scripts - name: Setup logrotate ansible.builtin.copy: dest: /etc/logrotate.d/borg owner: root group: root mode: '0644' content: | {{ borg_cron_log }} { daily rotate 7 missingok notifempty compress delaycompress } when: borg_logrotate