Skip to content
Snippets Groups Projects

[LOS-523] add automatic snapshot removal/purging

Merged Ben Morrice requested to merge lifecycle into master
4 files
+ 11
0
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 8
0
@@ -11,6 +11,14 @@ find $SOURCE -mindepth 1 -maxdepth 1 \( -type l -o -type d \) ! -path "*$TODAY"
$RESTIC backup --tag $TODAY --exclude-file=$EXCLUDE_LIST $SOURCE &>> $RESTIC_LOGFILE
rm -f $EXCLUDE_LIST
# Check if there are any snapshots to forget/purge
SNAPS_TO_REMOVE=`$RESTIC forget --dry-run --group-by paths --keep-within $PRUNE_SNAPSHOTS_OLDER_THAN | grep "remove .* snapshots" | awk '{print $2}'`
if [ ! -z $SNAPS_TO_REMOVE ]; then
echo "Found $SNAPS_TO_REMOVE snapshots that are older than $PRUNE_SNAPSHOTS_OLDER_THAN. Purging from restic store ..." >> $RESTIC_LOGFILE
$RESTIC unlock &>> $RESTIC_LOGFILE
$RESTIC forget --group-by paths --keep-within $PRUNE_SNAPSHOTS_OLDER_THAN --prune &>> $RESTIC_LOGFILE
fi
echo "Sending email of $RESTIC_LOG to admins"
export TODAY="$TODAY"
export RESTIC_LOG="`cat $RESTIC_LOGFILE`"
Loading