--- # 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