Initial commit

This commit is contained in:
2026-02-15 15:16:36 +01:00
commit 7c1a67be4e
12 changed files with 207 additions and 0 deletions

37
backup.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -euo pipefail
# Source environment vars (crond runs in a minimal env)
if [ -f /etc/restic-backup.env ]; then
set -a
. /etc/restic-backup.env
set +a
fi
echo "==> Backup started at $(date -Iseconds)"
# Run pre-backup hook
if [ -x /hooks/pre-backup.sh ]; then
echo "==> Running pre-backup hook"
/hooks/pre-backup.sh
fi
# Run restic backup
echo "==> Running restic backup: $BACKUP_SOURCE"
restic backup $BACKUP_SOURCE
# Apply retention policy
echo "==> Applying retention policy: daily=$KEEP_DAILY weekly=$KEEP_WEEKLY monthly=$KEEP_MONTHLY yearly=$KEEP_YEARLY"
restic forget --prune \
--keep-daily="$KEEP_DAILY" \
--keep-weekly="$KEEP_WEEKLY" \
--keep-monthly="$KEEP_MONTHLY" \
--keep-yearly="$KEEP_YEARLY"
# Run post-backup hook
if [ -x /hooks/post-backup.sh ]; then
echo "==> Running post-backup hook"
/hooks/post-backup.sh
fi
echo "==> Backup finished at $(date -Iseconds)"