Backup-Scripts/btrfs/snapshot

17 lines
327 B
Plaintext
Raw Normal View History

#!/bin/sh
#
# BTRFS rolling snapshots
# CC0 ~caskd
: ${SRC:?'Source not defined'}
: ${SNAPDIR:?'Snapdir not defined'}
: ${SELECTOR:='+%H'}
NAME="$(date "$SELECTOR")"
SNAPSRC="$SRC"
SNAPDEST="$SRC/$SNAPDIR/$NAME"
mkdir -p "${SNAPDEST%/*}"
btrfs subvolume delete "$SNAPDEST"
btrfs subvolume snapshot -r "$SNAPSRC" "$SNAPDEST"