Alert when the latest backup is older than N hours
Backup cron silently failed; nobody noticed; the gap surfaces only at the next incident. Need an alert when the newest backup file is older than 30 hours.
Recipe
#!/usr/bin/env bash
# Run hourly. Pings the heartbeat ONLY if a fresh backup exists.
# A missed ping = alert — exactly the dead-man-switch contract.
BACKUP_DIR="${BACKUP_DIR:-/var/backups/db}"
MAX_AGE_HOURS="${MAX_AGE_HOURS:-30}"
HEARTBEAT_URL="${HEARTBEAT_URL:?heartbeat URL required}"
NEWEST=$(find "$BACKUP_DIR" -type f -mmin -$((MAX_AGE_HOURS*60)) | head -1)
[ -n "$NEWEST" ] && curl -s -o /dev/null --max-time 10 "$HEARTBEAT_URL"
Same thing in Enterno.io
Enterno heartbeat monitors distinguish "no ping at all" from "ping with an error" — exactly what backup checks need: silence = alarm.
Related recipes
Your cron silently stopped running. Need an alert when the script misses its window.
A container OOM-kills, the restart policy revives it — no external signal until users complain.
Logs or backup files eat /var; in 24 hours the server falls over. A basic df check every 10 minutes saves a 2 AM incident.