#!/usr/bin/env bash set -e set -a . "{{ service_path }}/service.env" set +a hc_url="https://hc-ping.com/$HC_UID" _hc_ping () { curl -fsSL --retry 3 "$hc_url$1" >/dev/null } _hc_fail () { _hc_ping "/fail" exit 1 } _hc_ping "/start" duration_start=$(date +%s) BACKUP_LOCATION="$(mktemp -d)" export BACKUP_LOCATION cd "$BACKUP_LOCATION" || exit shopt -s nullglob for file in "{{ service_path }}/backup.d/"* do echo "" echo "running $file" time "$file" || _hc_fail done || true cd "{{ service_path }}" docker compose run --rm -v "$BACKUP_LOCATION:/backup/misc" app backup /backup || _hc_fail duration_end=$(date +%s) _hc_ping duration=$((duration_end - duration_start)) curl -fsSL --retry 3 "https://status.serguzim.me/api/push/$UPTIME_KUMA_TOKEN?status=up&msg=OK&ping=${duration}000" rm -rf "$BACKUP_LOCATION" echo "forgetting old backups for $(hostname)" docker compose run --rm app forget --host "$(hostname)" --prune \ --keep-daily 14 \ --keep-weekly 28 \ --keep-monthly 12 \ --keep-yearly 2