Files
Workstation/ansible/arch_backup/tasks/main.yml
ducoterra 9a3ee4fa9b Pull variables out of arch_backup
Pull out user-modifiable variables from arch_backup. This should make it
easier for anyone to modify.
2022-02-01 10:46:11 -05:00

59 lines
1.4 KiB
YAML

---
# Backup
- name: Create backup mount directory
file:
state: directory
path: "{{ mount.path }}"
become: yes
tags: backup
- name: Ensure {{ mount.path }} device exists in crypttab
community.general.crypttab:
name: "{{ disk.name }}"
backing_device: "UUID={{ disk.uuid }}"
password: "{{ disk.password }}"
opts: luks
state: present
become: yes
no_log: true
tags: backup
- name: Ensure {{ disk.name }} mount exists in fstab
ansible.posix.mount:
path: "{{ mount.path }}"
src: /dev/mapper/{{ disk.name }}
fstype: btrfs
opts: nofail,x-systemd.device-timeout=1,noatime,compress=zstd
state: present
become: yes
tags: backup
- name: Ensure /usr/local/scripts exists
file:
state: directory
path: '/usr/local/scripts'
become: yes
tags: backup
- name: Copy btrfs_backup.sh
ansible.builtin.copy:
src: scripts/btrfs_backup.sh
dest: /usr/local/scripts/btrfs_backup.sh
owner: root
group: root
mode: '0770'
become: yes
tags: backup
- name: Ensure hourly backups of each item in backups
ansible.builtin.cron:
name: "hourly backup of {{ item }}"
minute: "0"
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
state: restarted
daemon_reload: yes
enabled: yes
become: yes
tags: backup