summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@cozic.net>2017-05-08 20:14:15 +0000
committerLaurent Cozic <laurent@cozic.net>2017-05-08 20:14:15 +0000
commitd152279d301bf799c496d00d9b2aa706b46e88c6 (patch)
treeb8e2c729f54b7627b05c85bf62fa8feca16fd82b
parent15329de6033f5fc054a10d41277ce6ed69925edc (diff)
Still delete inprogress file in case of error or warning
-rwxr-xr-xrsync_tmbackup.sh21
1 files changed, 10 insertions, 11 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index 24170b8..ec643fa 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -406,28 +406,27 @@ while : ; do
# Check whether rsync reported any errors
# -----------------------------------------------------------------------------
+ EXIT_CODE="1"
if [ -n "$(grep "rsync error:" "$LOG_FILE")" ]; then
fn_log_error "Rsync reported an error. Run this command for more details: grep -E 'rsync:|rsync error:' '$LOG_FILE'"
- exit 1
- fi
-
- if [ -n "$(grep "rsync:" "$LOG_FILE")" ]; then
+ elif [ -n "$(grep "rsync:" "$LOG_FILE")" ]; then
fn_log_warn "Rsync reported a warning. Run this command for more details: grep -E 'rsync:|rsync error:' '$LOG_FILE'"
+ else
+ fn_log_info "Backup completed without errors."
+ if [[ $AUTO_DELETE_LOG == "1" ]]; then
+ rm -f -- "$LOG_FILE"
+ fi
+ EXIT_CODE="0"
fi
# -----------------------------------------------------------------------------
- # Add symlink to last successful backup
+ # Add symlink to last backup
# -----------------------------------------------------------------------------
fn_rm "$DEST_FOLDER/latest"
fn_ln "$(basename -- "$DEST")" "$DEST_FOLDER/latest"
fn_rm "$INPROGRESS_FILE"
- if [[ $AUTO_DELETE_LOG == "1" ]]; then
- rm -f -- "$LOG_FILE"
- fi
-
- fn_log_info "Backup completed without errors."
- exit 0
+ exit $EXIT_CODE
done