Pull variables out of arch_backup

Pull out user-modifiable variables from arch_backup. This should make it
easier for anyone to modify.
This commit is contained in:
ducoterra
2022-02-01 10:46:11 -05:00
parent fb2dd1174c
commit 9a3ee4fa9b
2 changed files with 25 additions and 21 deletions

View File

@@ -3,25 +3,25 @@
- name: Create backup mount directory
file:
state: directory
path: '/mnt/backup0'
path: "{{ mount.path }}"
become: yes
tags: backup
- name: Ensure backup0 device exists in crypttab
- name: Ensure {{ mount.path }} device exists in crypttab
community.general.crypttab:
name: backup0
backing_device: UUID=1d7ce570-e695-47a0-9dda-5f14b5b20e21
password: /home/ducoterra/.lukskeys/backup0
name: "{{ disk.name }}"
backing_device: "UUID={{ disk.uuid }}"
password: "{{ disk.password }}"
opts: luks
state: present
become: yes
no_log: true
tags: backup
- name: Ensure backup0 mount exists in fstab
- name: Ensure {{ disk.name }} mount exists in fstab
ansible.posix.mount:
path: /mnt/backup0
src: /dev/mapper/backup0
path: "{{ mount.path }}"
src: /dev/mapper/{{ disk.name }}
fstype: btrfs
opts: defaults,noatime,compress=zstd
opts: nofail,x-systemd.device-timeout=1,noatime,compress=zstd
state: present
become: yes
tags: backup
@@ -37,23 +37,17 @@
dest: /usr/local/scripts/btrfs_backup.sh
owner: root
group: root
mode: '0760'
mode: '0770'
become: yes
tags: backup
- name: Ensure hourly backups of /
- name: Ensure hourly backups of each item in backups
ansible.builtin.cron:
name: "hourly backup of /"
name: "hourly backup of {{ item }}"
minute: "0"
job: "export SOURCE_DIR=/; /usr/local/scripts/btrfs_backup.sh"
become: yes
tags: backup
- name: Ensure hourly backups of /home
ansible.builtin.cron:
name: "hourly backup of /home"
minute: "0"
job: "export SOURCE_DIR=/home; /usr/local/scripts/btrfs_backup.sh"
job: "export SOURCE_DIR={{ item }}; /usr/local/scripts/btrfs_backup.sh"
become: yes
tags: backup
loop: "{{ backups }}"
- name: Ensure cronie service started
ansible.builtin.systemd:
name: cronie

View File

@@ -1,2 +1,12 @@
---
# vars file for arch_backup
mount:
path: /mnt/backup0
disk:
name: backup0
uuid: 1d7ce570-e695-47a0-9dda-5f14b5b20e21
password: /home/ducoterra/.lukskeys/backup0
backups:
- /
- /home