mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-05 11:33:28 +01:00
Start improving systemd
This commit is contained in:
parent
b4727b17eb
commit
f385bfcb73
5 changed files with 10 additions and 22 deletions
|
@ -136,7 +136,8 @@ Available variables:
|
||||||
| `keep_within` | no | If set, only keeps snapshots in this time period. |
|
| `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. |
|
| `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. |
|
| `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_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_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 ) |
|
| `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) |
|
||||||
|
@ -151,7 +152,7 @@ restic_backups:
|
||||||
repo: remove
|
repo: remove
|
||||||
src: /path/to/data
|
src: /path/to/data
|
||||||
scheduled: true
|
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
|
> You can also specify restic_backups as an array, which is a legacy feature and
|
||||||
|
|
|
@ -13,5 +13,9 @@ restic_create_cron: false
|
||||||
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
|
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
|
||||||
restic_dir_group: '{{ 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)
|
# perform simple version check for this role? (true is recomended)
|
||||||
submodules_versioncheck: false
|
submodules_versioncheck: false
|
||||||
|
|
|
@ -23,4 +23,4 @@
|
||||||
loop: "{{ restic_repos|dict2items }}"
|
loop: "{{ restic_repos|dict2items }}"
|
||||||
when:
|
when:
|
||||||
- item.value.init is defined
|
- item.value.init is defined
|
||||||
- item.value.init
|
- item.value.init|bool
|
||||||
|
|
|
@ -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
|
- name: create systemd timer
|
||||||
block:
|
block:
|
||||||
- name: copy systemd timer
|
- name: copy systemd timer
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
Description=Run restic backup {{ item.name }} every night
|
Description=Run restic backup {{ item.name }} every night
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=*-*-* 02:00:00
|
OnCalendar=*-*-* 02:00:00 {{ restic_systemd_timer_default_OnCalendar }}
|
||||||
RandomizedDelaySec=3h
|
RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
|
||||||
Persistent=yes
|
Persistent=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
Loading…
Reference in a new issue