summaryrefslogtreecommitdiff
path: root/backup-dataset.sh
diff options
context:
space:
mode:
Diffstat (limited to 'backup-dataset.sh')
-rwxr-xr-xbackup-dataset.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/backup-dataset.sh b/backup-dataset.sh
new file mode 100755
index 0000000..e4303c5
--- /dev/null
+++ b/backup-dataset.sh
@@ -0,0 +1,27 @@
1#!/bin/sh -euf
2
3SNAPSHOT_DIRECTORY="/var/backups/dataset-snapshots"
4
5usage() (
6 echo "backup-dataset.sh <dataset> <duplicity destination> [duplicity options]"
7 echo
8 echo "Performs a duplicity incremental backup of the specified dataset."
9 echo "An atomic snapshot of the dataset is taken prior to backing up."
10 echo
11)
12
13backup_dataset() (
14 DATASET="$1"
15 DESTINATION="$2"
16 DUPLICITY_OPTIONS="$3"
17
18 sudo snap.sh snap "$DATASET"
19 PASSPHRASE="null" duplicity $DUPLICITY_OPTIONS "$SNAPSHOT_DIRECTORY/$DATASET" "$DESTINATION"
20 sudo snap.sh free "$DATASET"
21)
22
23case "${1:-help}" in
24 "help") usage;;
25 *) backup_dataset "$1" "$2" "${3:-}";;
26esac
27