X-Git-Url: https://git.treefish.org/~alex/backmeupscotty.git/blobdiff_plain/6b669353824a74a935077f40dd70662597d8922d..a2ef8e60326c6df9fa6191a022920caf5b604e8b:/backmeupscotty?ds=inline diff --git a/backmeupscotty b/backmeupscotty index ad2fa65..dd14711 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -6,14 +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 $_UPPERME: $@ + if [ $_ERROR_ENCOUNTERED -eq 0 ]; then + scottyline $@ + else + scottyline $@ >&2 + fi } function scottyerror { - echo $_UPPERME: $@ >&2 + scottyline $@ >&2 + _ERROR_ENCOUNTERED=1 } function ssh255 { @@ -108,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