infrastructure/playbooks/roles/backup/vars/main.yml

58 lines
2.3 KiB
YAML

---
backup_list: "{{ host_services | services_get_attr('backup') | flatten }}"
backup_list_all: "{{ all_services | services_get_attr('backup') | flatten }}"
backup_msg_start: "Backup started"
backup_msg_fail: "Backup failed"
backup_msg_fail_location: "Backup failed for location: "
backup_msg_success: "Backup successful"
backup_curl_base: 'curl -L -m 10 --retry 5'
backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"'
backup_gatus_curl_base: '{{ backup_curl_base }} -X POST -H "Authorization: Bearer {{ host_backup.gatus_token }}"'
backup_hc_url: '{{ host_backup.hc_url }}'
backup_gatus_url: 'https://status.serguzim.me/api/v1/endpoints/8-backups_backup@{{ ansible_facts.hostname }}/external'
backup_hc_command_start: '{{ backup_hc_curl_base }} --data "{{ backup_msg_start }}" {{ backup_hc_url }}/start'
backup_hc_command_success: '{{ backup_hc_curl_base }} --data "{{ backup_msg_success }}" {{ backup_hc_url }}'
backup_hc_command_fail: '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail }}" {{ backup_hc_url }}/fail'
backup_gatus_command_success: '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=true"'
backup_gatus_command_fail: '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail | urlencode }}"'
backup_default_hooks:
failure:
- '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail'
- '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}'
backup_global:
all:
cache-dir: "{{ (service_path, 'cache') | path_join }}"
retry-lock: 5m
forget:
keep-last: 7
keep-daily: 14
keep-weekly: 16
keep-monthly: 12
keep-yearly: 2
host: "{{ ansible_facts.hostname }}"
backup:
host: "{{ ansible_facts.hostname }}"
backup_yml:
version: 2
backends: "{{ vault_backup.backends }}"
locations: "{{ backup_list | map_backup_locations(vault_backup.backends, backup_default_hooks) }}"
global: "{{ backup_global }}"
backup_yml_all:
version: 2
backends: "{{ vault_backup.backends }}"
locations: "{{ backup_list_all | map_backup_locations(vault_backup.backends, backup_default_hooks) }}"
global: "{{ backup_global }}"