From a6245004a35a2236789b2ef9c44790fb0866fdcd Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Mon, 9 Sep 2019 14:28:25 +0200
Subject: [PATCH] added testfile to check a mounted volume

---
 README.md              |  4 ++--
 jobs/transfer.job.dist |  4 ++++
 transfer.sh            | 11 ++++++++++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 0971c3b..a792d37 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@ Runs on Linux.
 
 Free software. GNU GPL 3.0.
 
-Source: https://git-repo.iml.unibe.ch/iml-open-source/iml-backup/
-Duplicity: http://duplicity.nongnu.org/
+Source: <https://git-repo.iml.unibe.ch/iml-open-source/iml-backup/>
+Duplicity: <http://duplicity.nongnu.org/>
 
 ## Why ##
 
diff --git a/jobs/transfer.job.dist b/jobs/transfer.job.dist
index 0b0bf56..e4c071c 100644
--- a/jobs/transfer.job.dist
+++ b/jobs/transfer.job.dist
@@ -59,6 +59,10 @@ restore-path = /restore
 # use local filesystem or mounted device
 # storage = scp://imlbackup@lithium.iml.unibe.ch//netshare/backup/one
 
+# for file:// targets - you can add a test file that must be found
+# to detect that a backup volume is mounted
+# storage-file = /run/media/username/nas/I_am_mounted.txt
+
 # ssh-privatekey = /opt/imlbackup/client/keys/id_rsa_4_backupserver
 ssh-privatekey = 
 
diff --git a/transfer.sh b/transfer.sh
index a120bc7..04095e1 100755
--- a/transfer.sh
+++ b/transfer.sh
@@ -27,6 +27,7 @@
 # 2017-11-17  ah,ds  v1.5  check pid of lockfile in process list if process still runs
 # 2018-06-19  ah,ds  v1.6  replace --exclude with --exclude regexp in custom dirs
 # 2019-06-05  ah,ds  v1.7  add custom cache dir
+# 2019-09-09  ah,ds  v1.8  add testfile on target
 # ================================================================================
 
 
@@ -42,6 +43,7 @@
   typeset -i rc=0
 
   STORAGE_BASEDIR=`_j_getvar ${STORAGEFILE} "storage"`
+  STORAGE_TESTFILE=`_j_getvar ${STORAGEFILE} "storage-file"`
   STORAGE_KEEP=`_j_getvar ${STORAGEFILE} "keep"`
   STORAGE_VOLSIZE=`_j_getvar ${STORAGEFILE} "volsize"`
 
@@ -53,7 +55,14 @@
     color reset
     exit 1
   fi
-
+  if [ ! -z $STORAGE_TESTFILE -a ! -f $STORAGE_TESTFILE ]; then
+    color error
+    echo ERROR: missing testfile $STORAGE_TESTFILE on backup target.
+    echo The Backup target disk / NAS is not mounted.
+    color reset
+    exit 1
+  fi
+  
   if [ -z $STORAGE_KEEP ]; then
     color error
     echo ERROR: missing config for backup target.
-- 
GitLab