Files
seafile-backup/restic.sh
Jonathan Branan a29347686e
All checks were successful
continuous-integration/drone/push Build is passing
a
2026-01-28 20:00:24 -06:00

37 lines
1.3 KiB
Bash

#!/bin/ash
: "${RESTIC_REPOSITORY:?Need the restic repository}"
: "${AWS_ACCESS_KEY_ID:?Need the access key id}"
: "${AWS_SECRET_ACCESS_KEY:?Need the secret access key}"
: "${RESTIC_PASSWORD:?Need the restic password}"
: "${LOG_PATH:-/var/log/restic-backup.log}"
: "${seafile_data_local:-/seafile}"
restic snapshots > /dev/null || restic init
#Define a timestamp function
timestamp() {
date "+%b %d %Y %T %Z"
}
# insert timestamp into log
printf "\n\n"
echo "-------------------------------------------------------------------------------" | tee -a $LOG_PATH
echo "$(timestamp): restic-backup.sh started" | tee -a $LOG_PATH
# Run Backups
restic backup $seafile_data_local | tee -a $LOG_PATH
# Remove snapshots according to policy
# If run cron more frequently, might add --keep-hourly 24
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 7 | tee -a $LOG_PATH
# Remove unneeded data from the repository
restic prune | tee -a $LOG_PATH
# Check the repository for errors
restic check | tee -a $LOG_PATH
# insert timestamp into log
printf "\n\n"
echo "-------------------------------------------------------------------------------" | tee -a $LOG_PATH
echo "$(timestamp): restic-backup.sh finished" | tee -a $LOG_PATH