{{ salt.pillar.get("restic:server:mount:path") }}: mount.mounted: - device: {{ salt.pillar.get("restic:server:mount:device") | yaml_encode }} - fstype: {{ salt.pillar.get("restic:server:mount:fstype") | yaml_encode }} - mkmnt: {{ salt.pillar.get("restic:server:mount:mkmnt", True) | yaml_encode }} - persist: {{ salt.pillar.get("restic:server:mount:persist", True) | yaml_encode }} {% for name, minion_id in salt.pillar.get("restic:server:clients", {}).items() %} restic-{{ name }}: user.present: - home: {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }} - createhome: true - system: true - require: - mount: {{ salt.pillar.get("restic:server:mount:path") }} {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh: file.directory: - user: restic-{{ name }} - group: restic-{{ name }} - mode: 700 - require: - user: restic-{{ name }} {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh/authorized_keys: file.managed: - user: restic-{{ name }} - group: restic-{{ name }} - mode: 400 - contents: {{ salt.mine.get(minion_id, 'root_id_rsa_pub').get(minion_id, "") | yaml_encode }} - require: - file: {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh {% endfor %} bzip2: pkg.installed: [] {% 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' - template: jinja - unless: "/bin/restic version | grep 'restic {{ salt.pillar.get("restic:version") }} '" - require: - pkg: bzip2 {% 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 >/dev/null 2>&1" - identifier: restic backup - minute: random - hour: 4 - dayweek: 0 {% endif %}