This repository has been archived on 2023-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
salt-states_old/restic/init.sls
2022-11-03 13:27:06 +01:00

52 lines
1.3 KiB
Plaintext

{% 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:
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