summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbhuvi8 <bhuvibhuvanesh@gmail.com>2013-12-18 00:01:56 +0530
committerbhuvi8 <bhuvibhuvanesh@gmail.com>2013-12-18 00:01:56 +0530
commitc8ae23490478a014696ea78f8d662e6ab07ed5eb (patch)
tree7572a9538d6e57b3c72923c936c307586aa12490
parent25ad8f07a6bfc9dddb9d1cd10073d184c0cc399f (diff)
Deleting log file when no error is found and proper handling of rsync errors
through log file rather than through exit code
-rwxr-xr-xrsync_tmbackup.sh23
1 files changed, 9 insertions, 14 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index a32b1eb..dc108e1 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -214,7 +214,6 @@ while : ; do
touch -- "$INPROGRESS_FILE"
eval $CMD
- RSYNC_EXIT_CODE=$?
# -----------------------------------------------------------------------------
# Check if we ran out of space
@@ -223,8 +222,6 @@ while : ; do
# TODO: find better way to check for out of space condition without parsing log.
NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")"
- #rm -- "$LOG_FILE"
-
if [ -n "$NO_SPACE_LEFT" ]; then
fn_log_warn "No space left on device - removing oldest backup and resuming."
@@ -239,9 +236,12 @@ while : ; do
continue
fi
- if [ "$RSYNC_EXIT_CODE" != "0" ]; then
- fn_log_error "Exited with error code $RSYNC_EXIT_CODE"
- exit $RSYNC_EXIT_CODE
+ # -----------------------------------------------------------------------------
+ # 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."
+ exit 1
fi
# -----------------------------------------------------------------------------
@@ -252,14 +252,9 @@ while : ; do
ln -vs -- "$(basename -- "$DEST")" "$DEST_FOLDER/latest"
rm -f -- "$INPROGRESS_FILE"
+ rm -- "$LOG_FILE"
+
+ fn_log_info "Backup completed without errors."
- # -----------------------------------------------------------------------------
- # Check whether rsync reported any errors
- # -----------------------------------------------------------------------------
- if [[ "$(sed -n '/rsync error:/p;/rsync:/p' -- "$LOG_FILE" | wc -l)" -ge 1 ]]; then
- fn_log_error "rsync encountered error, please check $LOG_FILE for more details."
- else
- fn_log_info "Backup completed without errors."
- fi
exit 0
done