/
/
/
Ansible role that can run restic backups and push it to a remote storage server.
1---
2# Backup Role - Main Tasks
3#
4# backup_mode=backup back up everything on this host (see defaults/main.yml)
5# backup_mode=restore restore backup_services from their latest snapshot
6#
7# Repository maintenance (forget/prune/check) and the Home Assistant report
8# run once per backup, from backup.yml, via tasks_from: maintenance.
9
10- name: Validate backup mode
11 ansible.builtin.assert:
12 that:
13 - backup_mode in ['backup', 'restore']
14 - restic_password | length > 0
15 fail_msg: "backup_mode must be backup|restore, and restic_backup_password must be set in the vault"
16 tags: [always]
17
18- name: Normalize the service selection
19 ansible.builtin.set_fact:
20 _backup_selection: >-
21 {{ (backup_services.split(',') if backup_services is string else backup_services)
22 | map('trim') | reject('equalto', '') | list }}
23 tags: [always]
24
25- name: Install the pinned restic client
26 ansible.builtin.include_tasks: restic.yml
27 tags: [always]
28
29- name: Back up this host
30 ansible.builtin.include_tasks: backup-host.yml
31 when: backup_mode == 'backup'
32 tags: [always]
33
34- name: Restore selected services
35 ansible.builtin.include_tasks: restore-workflow.yml
36 when: backup_mode == 'restore'
37 tags: [always]
38