mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-09 21:33:31 +01:00
in case of systemd timers are used, remove possible installed cronjobs
This commit is contained in:
parent
619f4263e9
commit
9b8962cc5f
2 changed files with 26 additions and 0 deletions
18
tasks/restic_delete_cron.yml
Normal file
18
tasks/restic_delete_cron.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: remove restic backup cronjob
|
||||
ansible.builtin.cron:
|
||||
name: "do1jlr.restic backup {{ item.name }}"
|
||||
job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
||||
minute: '{{ item.schedule_minute | default("*") }}'
|
||||
hour: '{{ item.schedule_hour | default("2") }}'
|
||||
weekday: '{{ item.schedule_weekday | default("*") }}'
|
||||
month: '{{ item.schedule_month | default("*") }}'
|
||||
state: present
|
||||
user: 'root'
|
||||
cron_file: restic_backup
|
||||
become: true
|
||||
no_log: "{{ restic_no_log }}"
|
||||
with_items: '{{ restic_backups }}'
|
||||
when:
|
||||
- item.name is defined
|
||||
- item.scheduled | default(false)
|
|
@ -22,3 +22,11 @@
|
|||
when:
|
||||
- restic_create_schedule | bool
|
||||
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
||||
|
||||
- name: remove restic cronjobs
|
||||
ansible.builtin.include_tasks: restic_delete_cron.yml
|
||||
when:
|
||||
- restic_create_schedule | bool
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- not restic_force_cron | default(false)
|
||||
- restic_schedule_type != "cronjob"
|
||||
|
|
Loading…
Reference in a new issue