Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1dd5a4f98 | ||
|
|
df36126617 | ||
|
|
161fdfa8d1 |
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# check-backup-freshness — alert if the newest backup is older than 26h.
|
||||||
|
#
|
||||||
|
# Exit 0 = fresh (or no backups ever made and NONE expected yet)
|
||||||
|
# Exit 1 = stale: last backup dir older than MAX_HOURS, or no dir at all
|
||||||
|
# while the age recipient is configured (backups should exist).
|
||||||
|
#
|
||||||
|
# Wire it anywhere you like (cron, another timer, or run manually from the
|
||||||
|
# Mac after the daily pull). Not attached to any timer by itself — the only
|
||||||
|
# authorized timer in Tanda B is cayce-backup.timer.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BACKUP_ROOT="/var/backups/cayce"
|
||||||
|
MAX_HOURS=26
|
||||||
|
RECIPIENT_FILE="/etc/cayce-backup/age-recipient.pub"
|
||||||
|
|
||||||
|
newest="$(find "$BACKUP_ROOT" -mindepth 1 -maxdepth 1 -type d -name "2*-*-*" 2>/dev/null | sort | tail -1 || true)"
|
||||||
|
|
||||||
|
if [[ -z "$newest" ]]; then
|
||||||
|
if [[ -f "$RECIPIENT_FILE" ]]; then
|
||||||
|
echo "ALERT: no backups exist although the age recipient is configured" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "INFO: no backups yet (age recipient not configured) — nothing to alert"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
hours=$(( ( $(date +%s) - $(stat -c %Y "$newest") ) / 3600 ))
|
||||||
|
if (( hours > MAX_HOURS )); then
|
||||||
|
echo "ALERT: last backup ($newest) is ${hours}h old (max ${MAX_HOURS}h)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "OK: last backup ($newest) is ${hours}h old"
|
||||||
Reference in New Issue
Block a user