1
1

Fixed incompatibility of btrfs-snapshots with older Btrfs versions

This commit is contained in:
david 2024-07-18 19:40:46 +02:00
parent 476269b769
commit 1c163457db

View File

@ -17,12 +17,13 @@
##
NAME="btrfs-snapshots.sh"
VERSION="0.2.0"
VERSION="0.2.1"
AUTHOR="david@socialnerds.org"
LICENSE="MIT"
DESCRIPTION="Take read-only snapshots of BTRFS subvolumes."
WEBSITE="https://git.socialnerds.org/david/scripts"
CHANGELOG=("[2023-10-26][v0.2.0] Complete rewrite"
CHANGELOG=("[2024-07-18][v0.2.1] Fixes incompatibility with older Btrfs versions"
"[2023-10-26][v0.2.0] Complete rewrite"
"[2021-01-01][v0.1.0] Initial version")
@ -42,7 +43,7 @@ SNAP_NAME="$SNAP_PREFIX$SNAP_TIMESTAMP"
# Build the Btrfs command
BTRFS_BINARY="$(command -v btrfs)"
BTRFS_OPTIONS="-q"
BTRFS_OPTIONS=""
BTRFS_COMMAND="$BTRFS_BINARY $BTRFS_OPTIONS"
# How many snapshots should be kept?
@ -169,7 +170,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" >/dev/null 2>&1); then
lib_print "Created new snapshot [$SNAP_FOLDER/$SNAP_NAME]"
else
lib_print "!Error occured while creating new snapshot [$SNAP_FOLDER/$SNAP_NAME]"
@ -187,7 +188,7 @@ else
i=0
for SNAP in ${SNAPS[@]}; do
if [[ $i -ge $SNAPSHOTS ]]; then
if $($BTRFS_COMMAND subvolume delete "$SNAP_FOLDER/$SNAP"); then
if $($BTRFS_COMMAND subvolume delete "$SNAP_FOLDER/$SNAP" >/dev/null 2>&1); then
lib_print "Deleted old snapshot [$SNAP_FOLDER/$SNAP]"
else
lib_print "!Error occured while deleting old snapshot [$SNAP_FOLDER/$SNAP]"