Repos
Shell
618 B12 lines Opens in site
Directory
Raw
Download
#!/bin/bash
# backup-prune: enforce calendar retention (7 daily, 4 weekly, 6 monthly).
# Refuses to prune below the 30-day audit floor without explicit confirm.
set -u
command -v restic >/dev/null 2>&1 || { echo "restic not installed"; exit 3; }
REPO="${TOSV_RESTIC_REPO:?set TOSV_RESTIC_REPO}"
export RESTIC_REPOSITORY="$REPO" RESTIC_PASSWORD_FILE="${TOSV_RESTIC_PASSFILE:?set TOSV_RESTIC_PASSFILE}"
if [ "${TOSV_PRUNE_CONFIRM:-}" != "yes" ]; then
echo "refusing: set TOSV_PRUNE_CONFIRM=yes to prune (30-day floor guard)"
exit 2
fi
restic forget --tag tosv --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune