]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
removed script name from loglines
[backmeupscotty.git] / backmeupscotty
index ad2fa6582ec1303bef176c47eaab0335ee03da67..ff0f07ffa66104a53932bc3d428a61f0bdf80ee0 100644 (file)
@@ -6,14 +6,30 @@ ARCHIVE_KEEPNBACKUPS=30
 ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 
 ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 
-_UPPERME=$(echo $(basename $0) | tr '[:lower:]' '[:upper:]')
+_ERROR_ENCOUNTERED=0
+
+function timestamp {
+    date +'[%y-%m-%d|%H:%M:%S]'
+}
+
+function scottyline {
+    echo $(timestamp) $@
+}
 
 function scottyinfo {
 
 function scottyinfo {
-    echo $_UPPERME: $@ 
+    if [ $_ERROR_ENCOUNTERED -eq 0 ]; then
+       scottyline $@
+    else
+       scottyline $@ >&2
+    fi
 }
 
 function scottyerror {
 }
 
 function scottyerror {
-    echo $_UPPERME: $@ >&2 
+    scottyline $@ >&2
+    if [ $_ERROR_ENCOUNTERED -eq 0 ]; then
+       _ERROR_ENCOUNTERED=1
+       scottyline "Going into verbose mode after error encounter." >&2
+    fi
 }
 
 function ssh255 {
 }
 
 function ssh255 {
@@ -108,6 +124,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"
        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
     fi
 
     while [ $(grepbackups | wc -l) -gt $ARCHIVE_KEEPNBACKUPS ]; do