system/roles/backup/tasks/restic.yaml
Marty Oehme afac310f21
ref(roles): All roles use desired package state
By setting the `desired_package_state` variable we can change if ansible
should only ensure that the packages exist on the system (`present`) or
that they are also updated to their latest version (`latest`).
2025-03-13 11:24:14 +01:00

52 lines
1.4 KiB
YAML

- name: Install restic
community.general.xbps:
name:
- restic
state: "{{ desired_package_state | default('present') }}"
tags: packages
- name: Ensure restic configuration directory exists
ansible.builtin.file:
dest: "/etc/restic/root"
state: directory
- name: Create restic root backup configuration
ansible.builtin.template:
src: restic.conf.j2
dest: "/etc/restic/root/restic.conf"
mode: 0600
force: true # ensure contents are always exact
- name: Ensure files and exclude files exist # Only change if necessary
ansible.builtin.file:
dest: "/etc/restic/root/{{ item }}"
state: touch
modification_time: preserve
access_time: preserve
loop:
- include
- exclude
- name: Create include files # TODO: Rename file to include?
ansible.builtin.copy:
content: "/"
dest: "/etc/restic/root/include"
force: true # ensure contents are always exact
- name: Install snapstic script
ansible.builtin.copy:
src: snapstic
dest: "/usr/bin/snapstic"
mode: 0744
- name: Ensure restic configuration directory exists
ansible.builtin.file:
dest: "/etc/cron.weekly"
state: directory
- name: Add snapstic to weekly cronjobs
ansible.builtin.copy:
content: "#!/bin/sh\n\nsnapstic backup"
dest: "/etc/cron.weekly/snapstic"
mode: 0755
force: true # ensure contents are always exact