Files
salt-states/restic/init.sls
Keiran Snowden c1a5c8d95b combine states
2023-11-26 23:20:04 -05:00

68 lines
1.5 KiB
Plaintext

{% for client in salt.pillar.get("restic:server:clients", []) %}
restic-{{ client }}:
user.present:
- home: {{ salt.pillar.get("restic:server:mount") }}/{{ client }}
- createhome: true
- system: true
{% endfor %}
{% if salt.pillar.get("restic:client", None) is not none %}
{% if salt.pillar.get("restic:client:install", True)%}
'download restic':
cmd.script:
- shell: /bin/bash
- source: 'salt://restic/files/install.sh'
- templates: jinja
- unless: "/bin/restic version | grep 'restic 0.16.2 '"
- env:
- RESTIC_VERSION: 0.16.2
{% endif %}
/etc/logrotate.d/restic-backup:
file.managed:
- user: root
- group: root
- mode: 644
- contents: |
/var/log/restic/backup.log {
monthly
rotate 3
compress
missingok
notifempty
create 600 root root
}
restic dirs:
file.directory:
- user: root
- group: root
- mode: 700
- names:
- /opt/restic: []
- /var/log/restic: []
restic scripts:
file.managed:
- template: jinja
- user: root
- group: root
- mode: 700
- names:
- /opt/restic/env.sh:
- source: 'salt://restic/files/env.sh'
- /opt/restic/backup.sh:
- source: 'salt://restic/files/backup.sh'
- require:
- file: /opt/restic
restic cron:
cron.present:
- name: "/opt/restic/backup.sh 2>&1 >/dev/null"
- identifier: restic backup
- minute: random
- hour: 4
- dayweek: 0
{% endif %}