snapshotbackup

#!/bin/bash

# snapshotbackup
#
# Tom Wizetek <tom@wizetek.com>
# 2012-04-14

LOCATION="/BACKUPS"

[[ $1 = "" ]] && echo "Syntax:   $(basename $0) <subvolume> [snapshot description]" && exit 1
[[ $UID != 0 ]] && echo "$(basename $0): must run as root. Trying to sudo now..." && exec sudo $0 $@
[[ $2 != "" ]] && DESCRIPTION=${@:2} && DESCRIPTION=${DESCRIPTION// /.} || DESCRIPTION=$(date +%Y%m%d)

btrfs subvolume snapshot $LOCATION/$1 $LOCATION/$1-$DESCRIPTION