#!/bin/sh -euf SNAPSHOT_DIRECTORY="/var/backups/dataset-snapshots" usage() ( echo "backup-dataset.sh [duplicity options]" echo echo "Performs a duplicity incremental backup of the specified dataset." echo "An atomic snapshot of the dataset is taken prior to backing up." echo ) backup_dataset() ( DATASET="$1" DESTINATION="$2" DUPLICITY_OPTIONS="$3" sudo snap.sh snap "$DATASET" PASSPHRASE="null" duplicity $DUPLICITY_OPTIONS "$SNAPSHOT_DIRECTORY/$DATASET" "$DESTINATION" sudo snap.sh free "$DATASET" ) case "${1:-help}" in "help") usage;; *) backup_dataset "$1" "$2" "${3:-}";; esac