vps/playbooks/backup-services.yml

32 lines
868 B
YAML
Raw Normal View History

- name: Include variables files & run borg-init role
hosts: localhost
roles:
- include-vars
- borg-init
2024-05-14 19:12:39 +02:00
- backup-secrets
- name: Backup project(s)
hosts: localhost
vars:
run_backup: true
vars_prompt:
- name: selected_projects
prompt: "Choose projects to backup (leave empty to backup all. Projects list: {{ hostvars['localhost']['projects_to_backup'] }})"
private: false
unsafe: true
tasks:
- name: Backup project(s)
include_role:
name: "{{ project }}"
loop: "{{ (selected_projects | split) | default(projects_to_backup, true) }}"
loop_control:
# Do not use default variable name 'item' to prevent collisions with loops in roles.
loop_var: project
when: project in projects_to_backup
- name: Compact borg repository
hosts: localhost
roles:
- borg-compact