Allow override of dstdir with subvolume delta and add snapshot with retention

This commit is contained in:
Alex D. 2024-11-09 20:19:38 +00:00
parent bcd6f0f635
commit f641a5445e
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 19 additions and 1 deletions

View File

@ -3,7 +3,7 @@ set -e
SRC="$1"
RECV="$2"
DSTDIR="$SRC/.snap"
DSTDIR="$SRC/${3:-.snap}"
CDATE="$(date '+%s')"
PREV="prev"
CUR="cur"

18
btrfs/snapshot Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# BTRFS rolling snapshots
# CC0 ~caskd
: ${SRC:?'Source not defined'}
: ${DEST:?'Destination not defined'}
: ${NAME:?'Name not defined'}
: ${SN:?'Selection name not defined'}
: ${RT:?'Retention time not defined'}
s="$SRC"
d="$DEST/$SN/$NAME"
mkdir -p "${d%/*}"
find "$DEST" -mindepth 1 -maxdepth 1 -type d -ctime +"$RT" -exec echo "{}/$NAME" ';' | xargs btrfs subvolume del
btrfs subvolume delete "$d"
btrfs subvolume snapshot -r "$s" "$d"