added timer, fixed /root typo
This commit is contained in:
parent
ece28723c5
commit
38fbe9613f
@ -42,5 +42,5 @@ restic backup \
|
||||
--verbose \
|
||||
{% if pillar.podman is defined %}{{ salt['cmd.run']('podman info -f "{{.Store.VolumePath}}"', runas=pillar.podman.user ) }} \{% endif %}
|
||||
/etc \
|
||||
/ root \
|
||||
/root \
|
||||
/home
|
||||
|
10
restic/files/restic-backup.service.jinja
Normal file
10
restic/files/restic-backup.service.jinja
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Run restic backup
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User={{ pillar.restic.user }}
|
||||
ExecStart={{ salt['user.info'](pillar.restic.user).home }}/bin/backup.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
10
restic/files/restic-backup.timer.jinja
Normal file
10
restic/files/restic-backup.timer.jinja
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Restic backup timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ pillar.restic.OnCalendar }}
|
||||
RandomizedDelaySec=300
|
||||
Unit=restic-backup.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
@ -9,7 +9,7 @@ Install restic packages:
|
||||
- restic
|
||||
- restic-bash-completion
|
||||
|
||||
Copy backup script for {{ pillar.restic.user }}:
|
||||
Create backup script for {{ pillar.restic.user }}:
|
||||
file.managed:
|
||||
- name: {{ salt['user.info'](pillar.restic.user).home }}/bin/backup.sh
|
||||
- source: salt://restic/files/backup.sh.jinja
|
||||
@ -17,3 +17,35 @@ Copy backup script for {{ pillar.restic.user }}:
|
||||
- user: {{ pillar.restic.user }}
|
||||
- group: root
|
||||
- mode: "0740"
|
||||
|
||||
Create the restic backup service unit:
|
||||
file.managed:
|
||||
- name: /etc/systemd/system/restic-backup.service
|
||||
- source: salt://restic/files/restic-backup.service.jinja
|
||||
- template: jinja
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: "0644"
|
||||
|
||||
Create the restic backup timer:
|
||||
file.managed:
|
||||
- name: /etc/systemd/system/restic-backup.timer
|
||||
- source: salt://restic/files/restic-backup.timer.jinja
|
||||
- template: jinja
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: "0644"
|
||||
|
||||
Run systemctl daemon reload for restic:
|
||||
cmd.run:
|
||||
- name: systemctl daemon-reload
|
||||
- onchanges:
|
||||
- file: Create the restic backup service unit
|
||||
- file: Create the restic backup timer
|
||||
|
||||
Start the restic backup timer:
|
||||
service.running:
|
||||
- name: restic-backup.timer
|
||||
- enable: True
|
||||
- onchanges:
|
||||
- cmd: Run systemctl daemon reload for restic
|
||||
|
Reference in New Issue
Block a user