mirror of
https://github.com/laurent22/rsync-time-backup
synced 2024-11-10 14:14:16 +00:00
prevent execution of concurrent backup tasks
This commit is contained in:
parent
21c24be547
commit
5740b9a43e
1 changed files with 7 additions and 1 deletions
|
@ -113,6 +113,10 @@ fi
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
if [ -f "$INPROGRESS_FILE" ]; then
|
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
|
if [ -n "$PREVIOUS_DEST" ]; then
|
||||||
# - Last backup is moved to current backup folder so that it can be resumed.
|
# - Last backup is moved to current backup folder so that it can be resumed.
|
||||||
# - 2nd to last backup becomes last backup.
|
# - 2nd to last backup becomes last backup.
|
||||||
|
@ -123,6 +127,8 @@ if [ -f "$INPROGRESS_FILE" ]; then
|
||||||
else
|
else
|
||||||
PREVIOUS_DEST=""
|
PREVIOUS_DEST=""
|
||||||
fi
|
fi
|
||||||
|
# update PID to current process to avoid multiple concurrent resumes
|
||||||
|
echo "$$" > "$INPROGRESS_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -213,7 +219,7 @@ while : ; do
|
||||||
fn_log_info "Running command:"
|
fn_log_info "Running command:"
|
||||||
fn_log_info "$CMD"
|
fn_log_info "$CMD"
|
||||||
|
|
||||||
touch -- "$INPROGRESS_FILE"
|
echo "$$" > "$INPROGRESS_FILE"
|
||||||
eval $CMD
|
eval $CMD
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue