aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsystemd-zfs-partition-backup.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/systemd-zfs-partition-backup.sh b/systemd-zfs-partition-backup.sh
index 8a89718..f012451 100755
--- a/systemd-zfs-partition-backup.sh
+++ b/systemd-zfs-partition-backup.sh
@@ -6,6 +6,7 @@ test -f /etc/default/systemd-zfs-partition-backup &&\
6 source /etc/default/systemd-zfs-partition-backup 6 source /etc/default/systemd-zfs-partition-backup
7 7
8DISK_NAME=$1 8DISK_NAME=$1
9logger -p debug "disk: $DISK_NAME"
9 10
10function beep() { 11function beep() {
11 test -f /usr/bin/beep &&\ 12 test -f /usr/bin/beep &&\
@@ -21,16 +22,17 @@ function fail() {
21 22
22function start() { 23function start() {
23 UNIT_NAME=$(systemd-escape --suffix=automount $1) 24 UNIT_NAME=$(systemd-escape --suffix=automount $1)
24 systemctl start "$UNIT_NAME" || (fail "$UNIT_NAME not found." ; exit 1) 25 systemctl start "$UNIT_NAME" || (logger -p info "$UNIT_NAME not found." ; exit 1)
25} 26}
26 27
27function stop() { 28function stop() {
28 UNIT_NAME=$(systemd-escape --suffix=automount $1) 29 UNIT_NAME=$(systemd-escape --suffix=automount $1)
29 systemctl stop "$UNIT_NAME" || (fail "$UNIT_NAME not found." ; exit 1) 30 systemctl stop "$UNIT_NAME" || (logger -p info "$UNIT_NAME not found." ; exit 1)
30} 31}
31 32
32 33
33logger -p debug "disk: $DISK_NAME [esc]=> $DISK_NAME_ESCAPED" 34# we assume, that we can mount the device somewhere under media
35start "media/$DISK_NAME" # without leading slash for the unit file
34 36
35DATASETS_WITH_DISKNAME=($(zfs list -H -o name | grep $DISK_NAME)) 37DATASETS_WITH_DISKNAME=($(zfs list -H -o name | grep $DISK_NAME))
36 38
@@ -52,7 +54,6 @@ do
52 54
53 DISK_MOUNTPOINT="/media/$DISK_NAME" 55 DISK_MOUNTPOINT="/media/$DISK_NAME"
54 56
55 start "media/$DISK_NAME" # without leading slash for the unit file
56 57
57 if ! findmnt $DISK_MOUNTPOINT; then 58 if ! findmnt $DISK_MOUNTPOINT; then
58 logger -p debug "Expected to find disk '$DISK_NAME' mounted under '$DISK_MOUNTPOINT'. But it is not there. Aborting backup." 59 logger -p debug "Expected to find disk '$DISK_NAME' mounted under '$DISK_MOUNTPOINT'. But it is not there. Aborting backup."
@@ -94,7 +95,6 @@ do
94 fi 95 fi
95 fi 96 fi
96 97
97 stop "media/$DISK_NAME" # without leading slash for the unit file
98 98
99 beep -f 831 -l 120 -n -f 294 -l 200 -n -f 147 99 beep -f 831 -l 120 -n -f 294 -l 200 -n -f 147
100 else 100 else
@@ -102,3 +102,4 @@ do
102 fi 102 fi
103done 103done
104 104
105stop "media/$DISK_NAME" # without leading slash for the unit file
..