From 52376db2b529170c54d747c56df8619ffe8587a3 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 21 Dec 2013 18:27:46 +0800 Subject: [PATCH] OS X compatibility and splitted rsync errors and warnings - Fixed bug on OS X since "--" is not supported by sed. - Changed sed to grep for consistency with rest of the code. - Splitted handling of rsync errors/warnings - for errors we quit with an error code, for warnings we print a message but complete the backup process. --- rsync_tmbackup.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index dc108e1..a467755 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -239,8 +239,11 @@ while : ; do # ----------------------------------------------------------------------------- # Check whether rsync reported any errors # ----------------------------------------------------------------------------- - if [[ "$(sed -n '/rsync error:/p;/rsync:/p' -- "$LOG_FILE" | wc -l)" -ge 1 ]]; then - fn_log_error "Encountered error, please check $LOG_FILE for more details." + if [ -n "$(grep "rsync:" "$LOG_FILE")" ]; then + fn_log_warn "Rsync reported a warning, please check '$LOG_FILE' for more details." + fi + if [ -n "$(grep "rsync error:" "$LOG_FILE")" ]; then + fn_log_error "Rsync reported an error, please check '$LOG_FILE' for more details." exit 1 fi @@ -252,8 +255,8 @@ while : ; do ln -vs -- "$(basename -- "$DEST")" "$DEST_FOLDER/latest" rm -f -- "$INPROGRESS_FILE" - rm -- "$LOG_FILE" - + rm -f -- "$LOG_FILE" + fn_log_info "Backup completed without errors." exit 0