2023-08-31 17:55:25 +00:00
|
|
|
#!/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%/*}"
|
2024-11-22 11:44:59 +00:00
|
|
|
find "$DEST" -mindepth 1 -maxdepth 1 -type d -ctime +"$RT" -exec echo "{}/$NAME" ';' | xargs -r btrfs subvolume del
|
2023-08-31 17:55:25 +00:00
|
|
|
btrfs subvolume delete "$d"
|
|
|
|
btrfs subvolume snapshot -r "$s" "$d"
|