borgmatic : remplacement cron par timer systemdl
parent
6d6e32a7dc
commit
d781e110d9
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Restart timer
|
||||
service:
|
||||
name: borgmatic.timer
|
||||
state: restarted
|
||||
|
||||
- name: systemctl daemon-reload
|
||||
systemd:
|
||||
daemon_reload: true
|
|
@ -61,13 +61,27 @@
|
|||
register: borg_init
|
||||
changed_when: '"does not exist" in borg_init.stderr'
|
||||
|
||||
- name: Deploy borg cron
|
||||
- name: Deploy borgmatic systemd
|
||||
template:
|
||||
src: cron.d/borg.j2
|
||||
dest: /etc/cron.d/borg{{ borg.path_suffix | default('') }}
|
||||
src: "systemd/system/{{ item }}.j2"
|
||||
dest: /etc/systemd/system/{{ item }}
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- borgmatic.service
|
||||
- borgmatic.timer
|
||||
notify:
|
||||
- Restart timer
|
||||
- systemctl daemon-reload
|
||||
|
||||
- name: Indicate role in motd
|
||||
template:
|
||||
src: update-motd.d/04-service.j2
|
||||
dest: /etc/update-motd.d/04-borgbackup
|
||||
mode: 0755
|
||||
|
||||
- name: Enable timer
|
||||
service:
|
||||
name: borgmatic.timer
|
||||
enabled: true
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{{ ansible_header | comment }}
|
||||
|
||||
PATH=$PATH:/usr/sbin:/usr/bin:/usr/local/bin:/sbin:/bin
|
||||
|
||||
{% if borg.path_suffix is defined %}
|
||||
{{ 60 | random(seed=inventory_hostname) }} {{ 24 | random(seed=inventory_hostname) }} * * * root borgmatic -c /etc/borgmatic/config{{ borg.path_suffix }}.yaml --syslog-verbosity 1
|
||||
{% else %}
|
||||
{{ 60 | random(seed=inventory_hostname) }} {{ 24 | random(seed=inventory_hostname) }} * * * root borgmatic --syslog-verbosity 1
|
||||
{% endif %}
|
|
@ -0,0 +1,15 @@
|
|||
{{ ansible_header | comment }}
|
||||
|
||||
[Unit]
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
|
||||
{% if borg.path_suffix is defined %}
|
||||
ExecStart=borgmatic -c /etc/borgmatic/config{{ borg.path_suffix }}.yaml --syslog-verbosity 1
|
||||
{% else %}
|
||||
ExecStart=borgmatic --syslog-verbosity 1
|
||||
{% endif %}
|
|
@ -0,0 +1,10 @@
|
|||
{{ ansible_header | comment }}
|
||||
|
||||
[Unit]
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ 24 | random(seed=inventory_hostname) }}:{{ 60 | random(seed=inventory_hostname) }}
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue