From 77729dad7de8ca3ac6952c6a7832fed22f934d6b Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Tue, 25 Feb 2020 09:34:58 +0100 Subject: [PATCH] v1.11 fix test -z with non existing vars; show final backup status --- transfer.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/transfer.sh b/transfer.sh index 19de81d..9f63e85 100755 --- a/transfer.sh +++ b/transfer.sh @@ -29,6 +29,8 @@ # 2019-06-05 ah,ds v1.7 add custom cache dir # 2019-09-09 ah,ds v1.8 add testfile on target # 2019-10-30 ah,ds v1.9 for rsync targets: create remote target dir with ssh command +# 2020-01-21 ah,ds v1.10 show colored OK or FAILED at the end of output +# 2020-02-25 ah,ds, v1.11 fix test -z with non existing vars; show final backup status # ================================================================================ @@ -49,14 +51,14 @@ STORAGE_VOLSIZE=`_j_getvar ${STORAGEFILE} "volsize"` # check - if [ -z $STORAGE_BASEDIR ]; then + if [ -z "$STORAGE_BASEDIR" ]; then color error echo ERROR: missing config for backup target. echo There must be an entry storage in ${STORAGEFILE} color reset exit 1 fi - if [ ! -z $STORAGE_TESTFILE -a ! -f $STORAGE_TESTFILE ]; then + 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. @@ -64,7 +66,7 @@ exit 1 fi - if [ -z $STORAGE_KEEP ]; then + if [ -z "$STORAGE_KEEP" ]; then color error echo ERROR: missing config for backup target. echo There must be an entry keep in ${STORAGEFILE} @@ -338,6 +340,16 @@ j_transferEnd echo STATUS $0 exit with final returncode rc=$rc | tee -a $transferlog + echo | tee -a $transferlog + if [ $rc -eq 0 ]; then + color ok + echo Backup OK | tee -a $transferlog + else + color error + echo Backup FAILED :-/ | tee -a $transferlog + fi + color reset + echo | tee -a $transferlog echo `date` TRANSFER DONE | tee -a $transferlog ls -l $transferlog -- GitLab