1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic.git synced 2024-12-11 23:41:32 +01:00

Start improving systemd

This commit is contained in:
L3D 2021-06-15 19:48:23 +02:00 committed by Lilian
parent b4727b17eb
commit f385bfcb73
No known key found for this signature in database
GPG key ID: 5215C3441797AB2B
5 changed files with 10 additions and 22 deletions

View file

@ -136,7 +136,8 @@ Available variables:
| `keep_within` | no | If set, only keeps snapshots in this time period. |
| `keep_tag` | no | If set, keep snapshots with this tags. Make sure to specify a list. |
| `prune` | no (`false`) | If `true`, the `restic forget` command in the script has the [`--prune` option](https://restic.readthedocs.io/en/stable/060_forget.html#removing-backup-snapshots) appended. |
| `scheduled` | no (`false`) | If `restic_create_cron` is set to `true`, this backup is scheduled. |
| `scheduled` | no (`false`) | If `restic_create_cron` is set to `true`, this backup is scheduled and tries to create a systemd timer unit. If it fails, it is creating a cronjob. |
| `schedule_oncalendar` | ``'*-*-* 02:00:00'`` | The time for the systemd timer. Please notice the randomDelaySec option. By Default the backup is done every night at 2 am (+0-4h). But only if scheduled is true. |
| `schedule_minute` | no (`*`) | Minute when the job is run. ( 0-59, *, */2, etc ) |
| `schedule_hour` | no (`*`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
| `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) |
@ -151,7 +152,7 @@ restic_backups:
repo: remove
src: /path/to/data
scheduled: true
schedule_hour: 3
schedule_oncalendar: '*-*-* 01:00:00'
```
> You can also specify restic_backups as an array, which is a legacy feature and

View file

@ -13,5 +13,9 @@ restic_create_cron: false
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}'
# timer defaults
restic_systemd_timer_randomizeddelaysec: '4h'
restic_systemd_timer_default_OnCalendar: '*-*-* 02:00:00'
# perform simple version check for this role? (true is recomended)
submodules_versioncheck: false

View file

@ -23,4 +23,4 @@
loop: "{{ restic_repos|dict2items }}"
when:
- item.value.init is defined
- item.value.init
- item.value.init|bool

View file

@ -1,21 +1,4 @@
---
- name: cleanup old CRON jobs from migration
ansible.builtin.cron:
name: 'arillso.restic backup {{ item.name }}'
job: 'CRON=true {{ restic_script_dir }}/backup-{{ item.name }}.sh'
minute: '{{ item.schedule_minute | default("*") }}'
hour: '{{ item.schedule_hour | default("*") }}'
weekday: '{{ item.schedule_weekday | default("*") }}'
month: '{{ item.schedule_month | default("*") }}'
state: absent
become: true
no_log: true
with_items: '{{ restic_backups }}'
when:
- restic_create_cron
- item.name is defined
- item.scheduled | default(false)
- name: create systemd timer
block:
- name: copy systemd timer

View file

@ -2,8 +2,8 @@
Description=Run restic backup {{ item.name }} every night
[Timer]
OnCalendar=*-*-* 02:00:00
RandomizedDelaySec=3h
OnCalendar=*-*-* 02:00:00 {{ restic_systemd_timer_default_OnCalendar }}
RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
Persistent=yes
[Install]