]> arthur.barton.de Git - ax-linux.git/commitdiff
btrfs-mksnapshot: Only use first component of volume
authorAlexander Barton <alex@barton.de>
Sat, 4 Jan 2014 00:43:44 +0000 (01:43 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 4 Jan 2014 00:43:46 +0000 (01:43 +0100)
Only use the first component of a volume name that contains dashes ("-").

btrfs/mksnapshot/btrfs-mksnapshot

index 45289810034e2445f0922acd893cecb851ac24ad..a3fb8adca435426ca722adc9f6fa490335f19056 100755 (executable)
@@ -91,8 +91,6 @@ fi
 
 [ -z "$DRY_RUN" ] || echo "FS_MOUNT_PATH=$FS_MOUNT_PATH"
 
-[ -z "$DRY_RUN" ] || exit 0
-
 # Generate snapshot name
 i=1
 date=`date +%Y%m%d`
@@ -105,10 +103,15 @@ while true; do
        fi
        i=`expr $i + 1`
 done
+NEW_VOLUME_NAME="`echo $VOLUME_NAME | cut -d'-' -f1`-$id"
+
+[ -z "$DRY_RUN" ] || echo "NEW_VOLUME_NAME=$NEW_VOLUME_NAME"
+
+[ -z "$DRY_RUN" ] || exit 0
 
 echo "Creating snapshot of \"$VOLUME_PATH\" (\"$VOLUME_NAME\") in btrfs \"$FS_NAME\" ..."
 set -x
 
 cd "$FS_MOUNT_PATH"
-btrfs subvolume snapshot "$VOLUME_NAME" "$VOLUME_NAME-$id"
+btrfs subvolume snapshot "$VOLUME_NAME" "$NEW_VOLUME_NAME"
 find . -maxdepth 1 -name "$VOLUME_NAME"'*' -exec ls -1d {} \; | column