diff --git a/localhost.yml b/localhost.yml index fe84d2e..c03fa5b 100644 --- a/localhost.yml +++ b/localhost.yml @@ -14,6 +14,7 @@ - docker - laptop - desktop + - backup # - flutter # - virtual diff --git a/roles/backup/files/etc/btrbk/btrbk.conf b/roles/backup/files/etc/btrbk/btrbk.conf new file mode 100644 index 0000000..08c5d4f --- /dev/null +++ b/roles/backup/files/etc/btrbk/btrbk.conf @@ -0,0 +1,13 @@ +timestamp_format long + +snapshot_preserve_min 24h +snapshot_preserve 7d 4w 3m + +volume /home + snapshot_dir /home/.snapshots + subvolume /home + +volume / + snapshot_dir /.snapshot_dir + subvolume / + diff --git a/roles/backup/files/etc/cron.daily/btrbk b/roles/backup/files/etc/cron.daily/btrbk new file mode 100755 index 0000000..2d8693d --- /dev/null +++ b/roles/backup/files/etc/cron.daily/btrbk @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/btrbk -q run diff --git a/roles/backup/tasks/arch.yml b/roles/backup/tasks/arch.yml new file mode 100644 index 0000000..bcd7cb7 --- /dev/null +++ b/roles/backup/tasks/arch.yml @@ -0,0 +1,29 @@ +--- +- name: install btrbk + become: yes + community.general.pacman: + name: + - btrfs-progs + - btrbk + - cronie + +- name: "Enable cron" + become: yes + ansible.builtin.systemd: + name: cronie + state: started + enabled: yes + +- name: Copy configuration + become: yes + copy: + src: etc/btrbk/btrbk.conf + dest: /etc/btrbk/btrbk.conf + mode: 0644 + +- name: Add cron daily + become: yes + copy: + src: etc/cron.daily/btrbk + dest: /etc/cron.daily/btrbk + mode: 0755 diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml new file mode 100644 index 0000000..6d32278 --- /dev/null +++ b/roles/backup/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: arch.yml + when: ansible_distribution == "Archlinux"