From 5feb7e6727c650a5f6725fe5a71f24ed3d6c0490 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 30 Oct 2023 15:09:51 +0100 Subject: [PATCH] fixed a bug when btrfs subvol is / (second try) --- btrfs-snapshots.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/btrfs-snapshots.sh b/btrfs-snapshots.sh index d0c7508..9a8220c 100755 --- a/btrfs-snapshots.sh +++ b/btrfs-snapshots.sh @@ -158,11 +158,7 @@ if [[ -z "$1" ]]; then exit 0 else if is_subvolume "$1"; then - if [[ "$1" == "/" ]]; then - SNAP_FOLDER="/$SNAP_FOLDER" - else - SNAP_FOLDER="${1%/}/$SNAP_FOLDER" - fi + SNAP_FOLDER="${1%/}/$SNAP_FOLDER" # Create $SNAP_FOLDER if it does not exist if [[ ! -d "$SNAP_FOLDER" ]]; then lib_print "?Creating snapshot folder because it does not yet exist [$SNAP_FOLDER]" @@ -173,7 +169,7 @@ else else # Take the snapshot #TODO: handle failed snapshot creations - if $($BTRFS_COMMAND subvolume snapshot -r "${1%/}" "$SNAP_FOLDER/$SNAP_NAME"); then + if $($BTRFS_COMMAND subvolume snapshot -r "$1" "$SNAP_FOLDER/$SNAP_NAME"); then lib_print "Created new snapshot [$SNAP_FOLDER/$SNAP_NAME]" else lib_print "!Error occured while creating new snapshot [$SNAP_FOLDER/$SNAP_NAME]"