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.
This commit is contained in:
Laurent Cozic
2013-12-21 18:27:46 +08:00
parent c105c0a9e2
commit 52376db2b5
+6 -3
View File
@@ -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,7 +255,7 @@ 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."