1
1
Fork 0

fixed a bug when btrfs subvol is / (second try)

This commit is contained in:
david 2023-10-30 15:09:51 +01:00
parent 24af09986f
commit 5feb7e6727
1 changed files with 2 additions and 6 deletions

View File

@ -158,11 +158,7 @@ if [[ -z "$1" ]]; then
exit 0 exit 0
else else
if is_subvolume "$1"; then if is_subvolume "$1"; then
if [[ "$1" == "/" ]]; then SNAP_FOLDER="${1%/}/$SNAP_FOLDER"
SNAP_FOLDER="/$SNAP_FOLDER"
else
SNAP_FOLDER="${1%/}/$SNAP_FOLDER"
fi
# Create $SNAP_FOLDER if it does not exist # Create $SNAP_FOLDER if it does not exist
if [[ ! -d "$SNAP_FOLDER" ]]; then if [[ ! -d "$SNAP_FOLDER" ]]; then
lib_print "?Creating snapshot folder because it does not yet exist [$SNAP_FOLDER]" lib_print "?Creating snapshot folder because it does not yet exist [$SNAP_FOLDER]"
@ -173,7 +169,7 @@ else
else else
# Take the snapshot # Take the snapshot
#TODO: handle failed snapshot creations #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]" lib_print "Created new snapshot [$SNAP_FOLDER/$SNAP_NAME]"
else else
lib_print "!Error occured while creating new snapshot [$SNAP_FOLDER/$SNAP_NAME]" lib_print "!Error occured while creating new snapshot [$SNAP_FOLDER/$SNAP_NAME]"