From b2d3172c7f42c8f35033dc68b77f5d9c0559ede7 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Sat, 28 Oct 2017 10:53:29 +0200 Subject: [PATCH] Fix forget for backupdir '.' --- backupscript.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backupscript.sh b/backupscript.sh index 82cbf5e..7371223 100755 --- a/backupscript.sh +++ b/backupscript.sh @@ -87,10 +87,15 @@ fi export RESTIC_PASSWORD=${BACKUP_PASSWORD} -echo "Backup path: $SNAPSHOTDIR/$BDIR" +SNAPSHOTPATH=$SNAPSHOTDIR +if [[ -n "$BDIR" && "$BDIR" != "." ]]; then + SNAPSHOTPATH=$SNAPSHOTDIR/$BDIR +fi + +echo "Backup path: $SNAPSHOTPATH" # backup the snapshot (without freezing the filesystem) # use -q for quiet mode (when run as a cron job) -ionice -c 3 $RESTIC --repo $URI $EXCLUDE $QUIET backup $SNAPSHOTDIR/$BDIR +ionice -c 3 $RESTIC --repo $URI $EXCLUDE $QUIET backup "$SNAPSHOTPATH" ./lock.sh unlock $uuid @@ -102,7 +107,7 @@ if ! ./lock.sh haslock; then fi # delete everything older than the last X snapshots -$RESTIC --repo $URI $QUIET forget --keep-last $KEEPLAST --path "$SNAPSHOTDIR/$BDIR" +$RESTIC --repo $URI $QUIET forget --keep-last $KEEPLAST --path "$SNAPSHOTPATH" unset RESTIC_PASSWORD