summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@pogopixels.com>2015-02-15 10:57:48 +0100
committerLaurent Cozic <laurent@pogopixels.com>2015-02-15 10:57:48 +0100
commita728820bfd9d715bf45678ee2b36bd9aaba53ebb (patch)
treef160650d54d1eadde82731064f591ffee6f943df
parent21c24be547834b9182734150b629b6f4c43a0806 (diff)
parent5740b9a43ee8fa44627c13852afd16297d4878eb (diff)
Merge pull request #36 from eaut/avoid-concurrent
Prevent execution of concurrent backup tasks
-rwxr-xr-xrsync_tmbackup.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index b827075..553dcd6 100755
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -113,6 +113,10 @@ fi
# -----------------------------------------------------------------------------
if [ -f "$INPROGRESS_FILE" ]; then
+ if pgrep -F "$INPROGRESS_FILE" > /dev/null 2>&1 ; then
+ fn_log_error "Previous backup task is still active - aborting."
+ exit 1
+ fi
if [ -n "$PREVIOUS_DEST" ]; then
# - Last backup is moved to current backup folder so that it can be resumed.
# - 2nd to last backup becomes last backup.
@@ -123,6 +127,8 @@ if [ -f "$INPROGRESS_FILE" ]; then
else
PREVIOUS_DEST=""
fi
+ # update PID to current process to avoid multiple concurrent resumes
+ echo "$$" > "$INPROGRESS_FILE"
fi
fi
@@ -213,7 +219,7 @@ while : ; do
fn_log_info "Running command:"
fn_log_info "$CMD"
- touch -- "$INPROGRESS_FILE"
+ echo "$$" > "$INPROGRESS_FILE"
eval $CMD
# -----------------------------------------------------------------------------