feat(backup): Add restic backup
Restic backup creates a snapper snapshot of the root system which it then chroots into and starts a restic backup to a (wasabi) S3 bucket to. Intended to roughly follow this <https://codeberg.org/silmaril/my-restic-solution> solution to achieve restic backup of the _newest_ snapshot of my live root system.
This commit is contained in:
parent
2400bbf1af
commit
19162e2af3
6 changed files with 131 additions and 1 deletions
|
|
@ -2,4 +2,10 @@
|
|||
import_tasks: snapper.yaml
|
||||
tags:
|
||||
- btrfs
|
||||
- snapshots
|
||||
- snapper
|
||||
|
||||
- name: Set up restic backups
|
||||
import_tasks: restic.yaml
|
||||
tags:
|
||||
- btrfs
|
||||
- restic
|
||||
|
|
|
|||
52
roles/backup/tasks/restic.yaml
Normal file
52
roles/backup/tasks/restic.yaml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
- name: Install restic
|
||||
community.general.xbps:
|
||||
name:
|
||||
- restic
|
||||
state: 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue