backups: implement maintenance sub command

pull/1/head
earnest ma 2021-12-30 13:02:32 -05:00
parent ad9f9ac72d
commit b7acc5034d
Signed by: earnest ma
GPG Key ID: A343F43342EB6E2A
1 changed files with 26 additions and 2 deletions

View File

@ -89,8 +89,32 @@ Stopped $backup_stopped
$(cat ~/.restore-info/tmp/backup-log-${script_started}.txt)
EOMAIL
;;
prune)
echo "not implemented yet" ;;
maintenance)
restic forget -r "$repo" -v --prune \
--keep-last 2 --keep-daily 7 --keep-weekly 5 --keep-monthly 6 --keep-yearly 3 \
> ~/.restore-info/tmp/maint-forget-log-${script_started}.txt
forget_exit_code="$?"
restic -r "$repo" check --read-data-subset=10% \
> ~/.restore-info/tmp/maint-check-log-${script_started}.txt
check_exit_code="$?"
maint_done=$(date +%k%M%S)
cat <<EOMAIL | msmtp --read-envelope-from $BACKUP_EMAIL_TO
To: $BACKUP_EMAIL_TO
From: $BACKUP_EMAIL_FROM
Subject: Backup maintenance report: $script_started
- Finished $maint_done
- Forgetting exited $forget_exit_code
- Checking exiting $check_exit_code
$(cat ~/.restore-info/tmp/maint-forget-log-${script_started}.txt)
$(cat ~/.restore-info/tmp/maint-check-log-${script_started}.txt)
EOMAIL
;;
exec)
shift
restic -r "$repo" "$@" ;;