aboutsummaryrefslogtreecommitdiff
path: root/systemd-zfs-partition-backup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'systemd-zfs-partition-backup.sh')
-rwxr-xr-xsystemd-zfs-partition-backup.sh32
1 files changed, 21 insertions, 11 deletions
diff --git a/systemd-zfs-partition-backup.sh b/systemd-zfs-partition-backup.sh
index e40c241..aa3951f 100755
--- a/systemd-zfs-partition-backup.sh
+++ b/systemd-zfs-partition-backup.sh
@@ -1,16 +1,6 @@
1#!/usr/bin/bash 1#!/usr/bin/bash
2# Written in 2020 by Max Christian Pohle <webmaster@coderonline.de> 2# Written in 2020 by Max Christian Pohle <webmaster@coderonline.de>
3 3
4# check for a configuration file and source it in if its there
5test -f /etc/default/systemd-zfs-partition-backup &&\
6 source /etc/default/systemd-zfs-partition-backup
7
8DISK_NAME=$1
9DISK_NAME_ESCAPED=$(systemd-escape "$DISK_NAME")
10
11logger "Disk: $DISK_NAME"
12logger " : $DISK_NAME_ESCAPED (escaped)"
13
14function beep() { 4function beep() {
15 test -f /usr/bin/beep &&\ 5 test -f /usr/bin/beep &&\
16 env -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER -u SUDO_UID /usr/bin/beep $@ 6 env -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER -u SUDO_UID /usr/bin/beep $@
@@ -34,9 +24,29 @@ function stop() {
34} 24}
35 25
36 26
27
28# check for a configuration file and source it in if its there
29test -f /etc/default/systemd-zfs-partition-backup &&\
30 source /etc/default/systemd-zfs-partition-backup
31
32DISK_NAME=$1
33DISK_NAME_ESCAPED=$(systemd-escape "$DISK_NAME")
34
35logger "Disk: $DISK_NAME"
36logger " : $DISK_NAME_ESCAPED (escaped)"
37
38DATASETS_WITH_DISKNAME=$(zfs list -H -o name | grep $DISK_NAME)
39
40
41[ -z "$DATASETS_WITH_DISKNAME" ] &&\
42 (fail "no datasets found with name $DISK_NAME. Please create some." ; exit 1)
43
44logger "Datasets: $DATASETS_WITH_DISKNAME"
45
37# iterate over all datasets 46# iterate over all datasets
38for i in $(zfs list -H -o name); 47for i in ${DATASETS_WITH_DISKNAME[@]};
39do 48do
49 logger "assertion: $(basename $i) == $DISK_NAME"
40 # compare the 'tail' of the PATH against the disk name... 50 # compare the 'tail' of the PATH against the disk name...
41 if [ "$(basename $i)" == "$DISK_NAME" ]; then 51 if [ "$(basename $i)" == "$DISK_NAME" ]; then
42 start $DISK_NAME 52 start $DISK_NAME
..