Replace backup script with autorestic
This commit is contained in:
parent
13084e3558
commit
ed51a86935
17 changed files with 180 additions and 224 deletions
roles/backup/vars
|
@ -1,60 +1,46 @@
|
|||
---
|
||||
|
||||
backup_image: "{{ (container_registry.public, 'services/backup') | path_join }}"
|
||||
|
||||
backup_svc:
|
||||
name: backup
|
||||
|
||||
backup_volumes_list: "{{ all_services | my_service_attributes(inventory_hostname, 'volumes_backup') }}"
|
||||
backup_volumes_service: "{{ backup_volumes_list | map_backup_volumes_service }}"
|
||||
backup_list: "{{ all_services | my_service_attributes(inventory_hostname, 'backup') }}"
|
||||
|
||||
backup_env:
|
||||
HC_UID: "{{ host_backup.hc_uid }}"
|
||||
UPTIME_KUMA_TOKEN: "{{ host_backup.uptime_kuma_token }}"
|
||||
backup_msg_start: "Backup started"
|
||||
backup_msg_fail: "Backup failed"
|
||||
backup_msg_fail_location: "Backup failed for location: "
|
||||
backup_msg_success: "Backup successful"
|
||||
|
||||
RESTIC_REPOSITORY: "{{ vault_backup.restic.s3.repository }}"
|
||||
RESTIC_PASSWORD: "{{ vault_backup.restic.s3.password }}"
|
||||
backup_curl_base: 'curl -L -m 10 --retry 5'
|
||||
backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"'
|
||||
backup_uk_curl_base: '{{ backup_curl_base }}'
|
||||
backup_hc_url: 'https://hc-ping.com/{{ host_backup.hc_uid }}'
|
||||
backup_uk_url: 'https://status.serguzim.me/api/push/{{ host_backup.uptime_kuma_token }}'
|
||||
|
||||
AWS_ACCESS_KEY_ID: "{{ vault_backup.restic.s3.access_key_id }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ vault_backup.restic.s3.secret_access_key }}"
|
||||
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_uk_command_success: '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=up&msg={{ backup_msg_success | urlencode }}&ping="'
|
||||
backup_hc_command_fail: '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail }}" {{ backup_hc_url }}/fail'
|
||||
backup_uk_command_fail: '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=down&msg={{ backup_msg_fail | urlencode }}&ping="'
|
||||
|
||||
#RESTIC_S3_REPOSITORY: "{{ vault_backup.restic.s3.repository }}"
|
||||
#RESTIC_S3_PASSWORD: "{{ vault_backup.restic.s3.password }}"
|
||||
#RESITC_S3_ACCESS_KEY_ID: "{{ vault_backup.restic.s3.access_key_id }}"
|
||||
#RESITC_S3_SECRET_ACCESS_KEY: "{{ vault_backup.restic.s3.secret_access_key }}"
|
||||
backup_default_hooks:
|
||||
failure:
|
||||
- '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail'
|
||||
- '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=down&msg={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}&ping="'
|
||||
|
||||
#RESTIC_BORGBASE: "{{ vault_backup.restic.borgbase }}"
|
||||
backup_yml:
|
||||
version: 2
|
||||
|
||||
backup_compose:
|
||||
watchtower: false
|
||||
image: "{{ backup_image }}"
|
||||
volumes: "{{ backup_volumes_service }}"
|
||||
file:
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
entrypoint:
|
||||
- /usr/bin/restic
|
||||
- --retry-lock=1m
|
||||
restart: never
|
||||
hostname: "{{ ansible_facts.hostname }}"
|
||||
mount:
|
||||
build:
|
||||
context: .
|
||||
image: "{{ backup_image }}"
|
||||
restart: never
|
||||
hostname: "{{ ansible_facts.hostname }}"
|
||||
env_file:
|
||||
- service.env
|
||||
entrypoint:
|
||||
- /usr/bin/restic
|
||||
- --retry-lock=1m
|
||||
command:
|
||||
- mount
|
||||
- /mnt
|
||||
privileged: true
|
||||
devices:
|
||||
- /dev/fuse
|
||||
backends: "{{ vault_backup.locations }}"
|
||||
|
||||
volumes: "{{ backup_volumes_list | map_backup_volumes }}"
|
||||
locations: "{{ backup_list | map_backup_locations(vault_backup.locations, backup_default_hooks ) }}"
|
||||
|
||||
global:
|
||||
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 }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue