Fixed incompatibility of btrfs-snapshots with older Btrfs versions
This commit is contained in:
parent
476269b769
commit
1c163457db
@ -17,12 +17,13 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
NAME="btrfs-snapshots.sh"
|
NAME="btrfs-snapshots.sh"
|
||||||
VERSION="0.2.0"
|
VERSION="0.2.1"
|
||||||
AUTHOR="david@socialnerds.org"
|
AUTHOR="david@socialnerds.org"
|
||||||
LICENSE="MIT"
|
LICENSE="MIT"
|
||||||
DESCRIPTION="Take read-only snapshots of BTRFS subvolumes."
|
DESCRIPTION="Take read-only snapshots of BTRFS subvolumes."
|
||||||
WEBSITE="https://git.socialnerds.org/david/scripts"
|
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")
|
"[2021-01-01][v0.1.0] Initial version")
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ SNAP_NAME="$SNAP_PREFIX$SNAP_TIMESTAMP"
|
|||||||
|
|
||||||
# Build the Btrfs command
|
# Build the Btrfs command
|
||||||
BTRFS_BINARY="$(command -v btrfs)"
|
BTRFS_BINARY="$(command -v btrfs)"
|
||||||
BTRFS_OPTIONS="-q"
|
BTRFS_OPTIONS=""
|
||||||
BTRFS_COMMAND="$BTRFS_BINARY $BTRFS_OPTIONS"
|
BTRFS_COMMAND="$BTRFS_BINARY $BTRFS_OPTIONS"
|
||||||
|
|
||||||
# How many snapshots should be kept?
|
# How many snapshots should be kept?
|
||||||
@ -169,7 +170,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" >/dev/null 2>&1); 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]"
|
||||||
@ -187,7 +188,7 @@ else
|
|||||||
i=0
|
i=0
|
||||||
for SNAP in ${SNAPS[@]}; do
|
for SNAP in ${SNAPS[@]}; do
|
||||||
if [[ $i -ge $SNAPSHOTS ]]; then
|
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]"
|
lib_print "Deleted old snapshot [$SNAP_FOLDER/$SNAP]"
|
||||||
else
|
else
|
||||||
lib_print "!Error occured while deleting old snapshot [$SNAP_FOLDER/$SNAP]"
|
lib_print "!Error occured while deleting old snapshot [$SNAP_FOLDER/$SNAP]"
|
||||||
|
Loading…
Reference in New Issue
Block a user