X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=btrfs%2Fmksnapshot%2Fbtrfs-mksnapshot;h=ae7fff17d823da1e78dd7c9825305720f1e19294;hb=6ce66904a60ab1d8fb4063834ad0bfae8b7b5e20;hp=a3fb8adca435426ca722adc9f6fa490335f19056;hpb=17645219a2a79a4af90d23c2a44aa5fd29e615bf;p=ax-linux.git diff --git a/btrfs/mksnapshot/btrfs-mksnapshot b/btrfs/mksnapshot/btrfs-mksnapshot index a3fb8ad..ae7fff1 100755 --- a/btrfs/mksnapshot/btrfs-mksnapshot +++ b/btrfs/mksnapshot/btrfs-mksnapshot @@ -1,7 +1,7 @@ #!/bin/bash -e # # btrfs-mksnapshot -- Make snapshots of btrfs filesystems -# Copyright (c)2013 Alexander Barton (alex@barton.de) +# Copyright (c)2013-2014 Alexander Barton (alex@barton.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,8 +74,12 @@ if [ -z "$VOLUME_NAME" ]; then echo "$NAME: Failed to detect btrfs subvolume name for \"$VOLUME_PATH\"!" exit 1 fi +BASE_VOLUME_NAME=`echo "$VOLUME_NAME" | cut -d'@' -f1` -[ -z "$DRY_RUN" ] || echo "VOLUME_NAME=$VOLUME_NAME" +if [ -n "$DRY_RUN" ]; then + echo "VOLUME_NAME=$VOLUME_NAME" + echo "BASE_VOLUME_NAME=$BASE_VOLUME_NAME" +fi # Detect mount point of the whole btrfs filesystem FS_MOUNT_PATH="/media/$FS_NAME" @@ -96,14 +100,14 @@ i=1 date=`date +%Y%m%d` while true; do id="$date-$i" - [ -e "$FS_MOUNT_PATH/$VOLUME_NAME-$id" ] || break + [ -e "$FS_MOUNT_PATH/$BASE_VOLUME_NAME@$id" ] || break if [ -n "$ONLY_ONE_PER_DAY" ]; then - echo "Daily snapshot of \"$VOLUME_PATH\" (\"$VOLUME_NAME\") in btrfs \"$FS_NAME\" already exists." + echo "Snapshot \"$BASE_VOLUME_NAME@$id\" of \"$VOLUME_PATH\" (\"$VOLUME_NAME\") in btrfs \"$FS_NAME\" already exists." exit 0 fi i=`expr $i + 1` done -NEW_VOLUME_NAME="`echo $VOLUME_NAME | cut -d'-' -f1`-$id" +NEW_VOLUME_NAME="$BASE_VOLUME_NAME@$id" [ -z "$DRY_RUN" ] || echo "NEW_VOLUME_NAME=$NEW_VOLUME_NAME" @@ -114,4 +118,5 @@ set -x cd "$FS_MOUNT_PATH" btrfs subvolume snapshot "$VOLUME_NAME" "$NEW_VOLUME_NAME" -find . -maxdepth 1 -name "$VOLUME_NAME"'*' -exec ls -1d {} \; | column +find . -maxdepth 1 \( -name "$BASE_VOLUME_NAME" -o \ + -name "$BASE_VOLUME_NAME"@'*' \) -exec ls -1d {} \; | column