]> git.treefish.org Git - backmeupscotty.git/commitdiff
implemented verbose output after error encounter
authorAlexander Schmidt <alex@treefish.org>
Mon, 20 Jul 2015 22:06:23 +0000 (00:06 +0200)
committerAlexander Schmidt <alex@treefish.org>
Mon, 20 Jul 2015 22:06:23 +0000 (00:06 +0200)
backmeupscotty

index 152cf86261a0bd3db7becdd8d15319a1349ee670..80392a3b277ca6144651f413c4cd312a583e40c2 100644 (file)
@@ -6,18 +6,28 @@ ARCHIVE_KEEPNBACKUPS=30
 ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 
+_ERROR_ENCOUNTERED=0
 _UPPERME=$(echo $(basename $0) | tr '[:lower:]' '[:upper:]')
 
 function timestamp {
     date +"[%y-%m-%d %H:%M:%S]"
 }
 
+function scottyline {
+    echo $(timestamp) $_UPPERME: $@
+}
+
 function scottyinfo {
-    echo $(timestamp) $_UPPERME: $@ 
+    if ($_ERROR_ENCOUNTERED -eq 0); then
+       scottyline $@
+    else
+       scottyline $@ >&2
+    fi
 }
 
 function scottyerror {
-    echo $(timestamp) $_UPPERME: $@ >&2 
+    scottyline $@ >&2
+    _ERROR_ENCOUNTERED=1
 }
 
 function ssh255 {
@@ -112,6 +122,8 @@ function scottysync {
        scottyinfo "Timestamping completed backup and linking to current backup."
        ssh255 $REMOTE_HOST \
            "mv $dir_incomplete $dir_timestamped && rm -f $dir_current && ln -s $(basename $dir_timestamped) $dir_current"
+    else
+       scottyerror "Rsync failed."
     fi
 
     while [ $(grepbackups | wc -l) -gt $ARCHIVE_KEEPNBACKUPS ]; do