From ef98fe08b93f295229db166761388a7b343a40b6 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sun, 21 Aug 2016 21:46:52 +0200 Subject: [PATCH] Add support for forgetting and pruning --- restic-cron | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/restic-cron b/restic-cron index 7fb06ed..20df26f 100755 --- a/restic-cron +++ b/restic-cron @@ -45,6 +45,26 @@ if [ $status -ne 0 ]; then exit 2 fi +# Forget old snapshots +test -z "$RESTIC_QUIET" && echo "I: Forget step…" +restic $RESTIC_QUIET forget $RESTIC_FORGET_OPTIONS +status=$? +if [ $status -ne 0 ]; then + echo "E: Exit code was $status" + notify "Was not able to forget old snapshots!" + exit 3 +fi + +# Prune the repository +test -z "$RESTIC_QUIET" && echo "I: Prune step…" +restic $RESTIC_QUIET prune +status=$? +if [ $status -ne 0 ]; then + echo "E: Exit code was $status" + notify "Was not able to prune the repository!" + exit 4 +fi + # Verify the backup test -z "$RESTIC_QUIET" && echo "I: Check step…" restic $RESTIC_QUIET check @@ -52,7 +72,7 @@ status=$? if [ $status -ne 0 ]; then echo "E: Exit code was $status" notify "Repository check of the backup failed!" - exit 3 + exit 5 fi notify "Backup finished!"