{% if pillar.restic.repository is defined %}
include:
- restic.repository
{% endif %}
Install restic packages:
pkg.installed:
- pkgs:
- restic
- restic-bash-completion
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
- template: jinja
- user: {{ pillar.restic.user }}
- group: root
- mode: "0740"
Create the restic backup service unit:
- name: /etc/systemd/system/restic-backup.service
- source: salt://restic/files/restic-backup.service.jinja
- user: root
- mode: "0644"
Create the restic backup timer:
- name: /etc/systemd/system/restic-backup.timer
- source: salt://restic/files/restic-backup.timer.jinja
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
- cmd: Run systemctl daemon reload for restic