Improve backup service
This commit is contained in:
parent
9b7b5d3642
commit
33d5e30ba6
5 changed files with 26 additions and 18 deletions
|
@ -10,26 +10,26 @@ all:
|
||||||
|
|
||||||
node002:
|
node002:
|
||||||
ansible_host: "{{ opentofu.hosts.node002.fqdn_vpn }}"
|
ansible_host: "{{ opentofu.hosts.node002.fqdn_vpn }}"
|
||||||
ansible_port: "{{ vault_node002.ansible_port }}"
|
ansible_port: "{{ vault_hosts.node002.ansible_port }}"
|
||||||
ansible_user: "{{ vault_node002.ansible_user }}"
|
ansible_user: "{{ vault_hosts.node002.ansible_user }}"
|
||||||
interactive_user: "{{ vault_node002.interactive_user }}"
|
interactive_user: "{{ vault_hosts.node002.interactive_user }}"
|
||||||
host_vpn:
|
host_vpn:
|
||||||
domain: "{{ opentofu.hosts.node002.fqdn_vpn }}"
|
domain: "{{ opentofu.hosts.node002.fqdn_vpn }}"
|
||||||
ip: "{{ opentofu.hosts.node002.ipv4_address_vpn }}"
|
ip: "{{ opentofu.hosts.node002.ipv4_address_vpn }}"
|
||||||
host_backup:
|
host_backup:
|
||||||
hc_uid: "{{ opentofu.healthchecksio.backup.node002.id }}"
|
hc_uid: "{{ opentofu.healthchecksio.backup.node002.id }}"
|
||||||
hc_url: "{{ opentofu.healthchecksio.backup.node002.ping_url }}"
|
hc_url: "{{ opentofu.healthchecksio.backup.node002.ping_url }}"
|
||||||
uptime_kuma_token: "{{ vault_node002.backup.uptime_kuma_token }}"
|
gatus_token: "{{ vault_hosts.node002.backup.gatus_token }}"
|
||||||
|
|
||||||
node003:
|
node003:
|
||||||
ansible_host: "{{ opentofu.hosts.node003.fqdn_vpn }}"
|
ansible_host: "{{ opentofu.hosts.node003.fqdn_vpn }}"
|
||||||
ansible_port: "{{ vault_node003.ansible_port }}"
|
ansible_port: "{{ vault_hosts.node003.ansible_port }}"
|
||||||
ansible_user: "{{ vault_node003.ansible_user }}"
|
ansible_user: "{{ vault_hosts.node003.ansible_user }}"
|
||||||
interactive_user: "{{ vault_node003.interactive_user }}"
|
interactive_user: "{{ vault_hosts.node003.interactive_user }}"
|
||||||
host_vpn:
|
host_vpn:
|
||||||
domain: "{{ opentofu.hosts.node003.fqdn_vpn }}"
|
domain: "{{ opentofu.hosts.node003.fqdn_vpn }}"
|
||||||
ip: "{{ opentofu.hosts.node003.ipv4_address_vpn }}"
|
ip: "{{ opentofu.hosts.node003.ipv4_address_vpn }}"
|
||||||
host_backup:
|
host_backup:
|
||||||
hc_uid: "{{ opentofu.healthchecksio.backup.node003.id }}"
|
hc_uid: "{{ opentofu.healthchecksio.backup.node003.id }}"
|
||||||
hc_url: "{{ opentofu.healthchecksio.backup.node003.ping_url }}"
|
hc_url: "{{ opentofu.healthchecksio.backup.node003.ping_url }}"
|
||||||
uptime_kuma_token: "{{ vault_node003.backup.uptime_kuma_token }}"
|
gatus_token: "{{ vault_hosts.node003.backup.gatus_token }}"
|
||||||
|
|
|
@ -15,7 +15,7 @@ class FilterModule(object):
|
||||||
|
|
||||||
new_location = {
|
new_location = {
|
||||||
"to": backends_list,
|
"to": backends_list,
|
||||||
"forget": "yes",
|
"forget": "no",
|
||||||
"hooks": copy.deepcopy(hooks)
|
"hooks": copy.deepcopy(hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,7 @@
|
||||||
chdir: "{{ service_path }}"
|
chdir: "{{ service_path }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: true
|
become: true
|
||||||
|
register: cmd_result_verify
|
||||||
|
until: "cmd_result_verify is not failed"
|
||||||
|
retries: 10
|
||||||
|
delay: 10
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
if autorestic backup -av --ci
|
if autorestic backup -av --ci
|
||||||
then
|
then
|
||||||
{{ backup_hc_command_success }}
|
{{ backup_hc_command_success }}
|
||||||
{{ backup_uk_command_success }}
|
{{ backup_gatus_command_success }}
|
||||||
else
|
else
|
||||||
{{ backup_hc_command_fail }}
|
{{ backup_hc_command_fail }}
|
||||||
{{ backup_uk_command_fail }}
|
{{ backup_gatus_command_fail }}
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,29 +12,33 @@ backup_msg_success: "Backup successful"
|
||||||
|
|
||||||
backup_curl_base: 'curl -L -m 10 --retry 5'
|
backup_curl_base: 'curl -L -m 10 --retry 5'
|
||||||
backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"'
|
backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"'
|
||||||
backup_uk_curl_base: '{{ backup_curl_base }}'
|
backup_gatus_curl_base: '{{ backup_curl_base }} -X POST -H "Authorization: Bearer {{ host_backup.gatus_token }}"'
|
||||||
backup_hc_url: '{{ host_backup.hc_url }}'
|
backup_hc_url: '{{ host_backup.hc_url }}'
|
||||||
backup_uk_url: 'https://status.serguzim.me/api/push/{{ host_backup.uptime_kuma_token }}'
|
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_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_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_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="'
|
|
||||||
|
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:
|
backup_default_hooks:
|
||||||
failure:
|
failure:
|
||||||
- '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail'
|
- '{{ 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="'
|
- '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}'
|
||||||
|
|
||||||
backup_yml:
|
backup_yml:
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
backends: "{{ vault_backup.locations }}"
|
backends: "{{ vault_backup.backends }}"
|
||||||
|
|
||||||
locations: "{{ backup_list | map_backup_locations(vault_backup.locations, backup_default_hooks ) }}"
|
locations: "{{ backup_list | map_backup_locations(vault_backup.backends, backup_default_hooks ) }}"
|
||||||
|
|
||||||
global:
|
global:
|
||||||
|
all:
|
||||||
|
cache-dir: "{{ (service_path, 'cache') | path_join }}"
|
||||||
|
retry-lock: 5m
|
||||||
forget:
|
forget:
|
||||||
keep-last: 7
|
keep-last: 7
|
||||||
keep-daily: 14
|
keep-daily: 14
|
||||||
|
|
Loading…
Reference in a new issue