Initial commit
This commit is contained in:
37
backup.sh
Normal file
37
backup.sh
Normal 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)"
|
||||
Reference in New Issue
Block a user