19 lines
455 B
Plaintext
19 lines
455 B
Plaintext
|
#!/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"
|