X-Git-Url: https://git.treefish.org/~alex/backmeupscotty.git/blobdiff_plain/5e8b95f582e1327273442cc2ad0388aec5165d9c..c5f074f40b959c83a23cf6bf065e0ce27096032e:/backmeupscotty?ds=inline diff --git a/backmeupscotty b/backmeupscotty index 1d09266..ff0f07f 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -6,16 +6,30 @@ ARCHIVE_KEEPNBACKUPS=30 ARCHIVE_KEEPNDAYS=30 BACKUP_RUNEVERYNTHDAY=1 -function 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 { - echo $(upperme): $@ + if [ $_ERROR_ENCOUNTERED -eq 0 ]; then + scottyline $@ + else + scottyline $@ >&2 + fi } 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 { @@ -110,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" + else + scottyerror "Rsync failed." fi while [ $(grepbackups | wc -l) -gt $ARCHIVE_KEEPNBACKUPS ]; do