install.fairie/home/dot_config/autorestic/private_autorestic-system.yml.tmpl
2024-01-03 01:40:12 +00:00

70 lines
5.5 KiB
Cheetah

---
version: 2
extras:
docker: &docker
type: volume
to:
- docker-local
- docker-s3
cron: '0 * * * *'
hooks:
before:
- |
HEALTHCHECK_UUID="$(curl https://health.{{ .host.domain }}/api/v1/checks/ --header "X-Api-Key: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "HEALTHCHECKS_API_KEY")) }}{{ includeTemplate "secrets/HEALTHCHECKS_API_KEY" | decrypt | trim }}{{ else }}{{ default "" (env "HEALTHCHECKS_API_KEY") }}{{ end }}" --data "{\"name\": \"Autorestic Docker Volume Backup - Volume ${AUTORESTIC_LOCATION} / Host {{ .host.hostname }} / User {{ .user.username }})\", \"channels\": \"*\", \"schedule\": \"50 * * * *\", \"tags\": \"host-{{ .host.hostname }} user-{{ .user.username }} location-${AUTORESTIC_LOCATION} docker-volume\", \"tz\": \"{{ .user.timezone }}\", \"desc\": \"The ${AUTORESTIC_LOCATION} Docker volume on {{ .host.hostname }}\", \"grace\": 3600}" | jq -r '.ping_url' | sed 's/.*\///')"
curl -X POST -H "Content-Type: text/plain" --data "Autorestic Docker Volume ${AUTORESTIC_LOCATION} BEFORE / Host: ${HOST} / User: ${USER} / Home: ${HOME}" "https://health.{{ .host.domain }}/ping/${HEALTHCHECK_UUID}/start"
failure:
- |
HEALTHCHECK_UUID="$(curl https://health.{{ .host.domain }}/api/v1/checks/ --header "X-Api-Key: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "HEALTHCHECKS_API_KEY")) }}{{ includeTemplate "secrets/HEALTHCHECKS_API_KEY" | decrypt | trim }}{{ else }}{{ default "" (env "HEALTHCHECKS_API_KEY") }}{{ end }}" --data "{\"name\": \"Autorestic Docker Volume Backup - Volume ${AUTORESTIC_LOCATION} / Host {{ .host.hostname }} / User {{ .user.username }})\", \"channels\": \"*\", \"schedule\": \"50 * * * *\", \"tags\": \"host-{{ .host.hostname }} user-{{ .user.username }} location-${AUTORESTIC_LOCATION} docker-volume\", \"tz\": \"{{ .user.timezone }}\", \"desc\": \"The ${AUTORESTIC_LOCATION} Docker volume on {{ .host.hostname }}\", \"grace\": 3600}" | jq -r '.ping_url' | sed 's/.*\///')"
curl -X POST -H "Content-Type: text/plain" --data "Autorestic Docker Volume ${AUTORESTIC_LOCATION} FAILURE / Host: ${HOST} / User: ${USER} / Home: ${HOME}" "https://health.{{ .host.domain }}/ping/${HEALTHCHECK_UUID}/fail"
success:
- |
HEALTHCHECK_UUID="$(curl https://health.{{ .host.domain }}/api/v1/checks/ --header "X-Api-Key: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "HEALTHCHECKS_API_KEY")) }}{{ includeTemplate "secrets/HEALTHCHECKS_API_KEY" | decrypt | trim }}{{ else }}{{ default "" (env "HEALTHCHECKS_API_KEY") }}{{ end }}" --data "{\"name\": \"Autorestic Docker Volume Backup - Volume ${AUTORESTIC_LOCATION} / Host {{ .host.hostname }} / User {{ .user.username }})\", \"channels\": \"*\", \"schedule\": \"50 * * * *\", \"tags\": \"host-{{ .host.hostname }} user-{{ .user.username }} location-${AUTORESTIC_LOCATION} docker-volume\", \"tz\": \"{{ .user.timezone }}\", \"desc\": \"The ${AUTORESTIC_LOCATION} Docker volume on {{ .host.hostname }}\", \"grace\": 3600}" | jq -r '.ping_url' | sed 's/.*\///')"
curl -X POST -H "Content-Type: text/plain" --data "Autorestic Docker Volume ${AUTORESTIC_LOCATION} SUCCESS / Host: ${HOST} / User: ${USER} / Home: ${HOME}" "https://health.{{ .host.domain }}/ping/${HEALTHCHECK_UUID}"
options:
backup:
exclude:
- .venv
- node_modules
- venv
tag:
- docker
forget:
keep-hourly: 24
keep-daily: 7
keep-weekly: 12
keep-monthly: 8
keep-yearly: 1
locations:
healthchecks_config:
from: healthchecks_config
<<: *docker
healthchecks_postgres:
from: healthchecks_postgres
<<: *docker
rundeck_data:
from: rundeck_data
<<: *docker
portainer_manager_data:
from: portainer_manager_data
<<: *docker
statping_app:
from: statping_app
<<: *docker
statping_postgres:
from: statping_postgres
<<: *docker
backends:
docker-local:
type: local
path: /var/local/backups/docker
key: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "RESTIC_SYSTEM_PASSWORD")) }}{{ includeTemplate "secrets/RESTIC_SYSTEM_PASSWORD" | decrypt | trim }}{{ else }}{{ default "" (env "RESTIC_SYSTEM_PASSWORD") }}{{ end }}
docker-s3:
type: s3
path: {{ .user.cloudflare.r2 }}.r2.cloudflarestorage.com/docker
key: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "RESTIC_SYSTEM_PASSWORD")) }}{{ includeTemplate "secrets/RESTIC_SYSTEM_PASSWORD" | decrypt | trim }}{{ else }}{{ default "" (env "RESTIC_SYSTEM_PASSWORD") }}{{ end }}
env:
AWS_ACCESS_KEY_ID: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_ID")) }}{{ includeTemplate "secrets/CLOUDFLARE_R2_ID" | decrypt | trim }}{{ else }}{{ default "" (env "CLOUDFLARE_R2_ID") }}{{ end }}
AWS_SECRET_ACCESS_KEY: {{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_SECRET")) }}{{ includeTemplate "secrets/CLOUDFLARE_R2_SECRET" | decrypt | trim }}{{ else }}{{ default "" (env "CLOUDFLARE_R2_SECRET") }}{{ end }}