Merge pull request #80 from dovecode/cygwin-conflict-support
Add cygwin support for checking if the previous backup is still running
This commit is contained in:
+14
-4
@@ -269,10 +269,20 @@ fi
|
|||||||
|
|
||||||
if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
|
if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
|
||||||
if [ "$OSTYPE" == "cygwin" ]; then
|
if [ "$OSTYPE" == "cygwin" ]; then
|
||||||
# TODO: Cygwin reports the name of currently running Bash scripts as just "/usr/bin/bash"
|
# 1. Grab the PID of previous run from the PID file
|
||||||
# TODO: so the pgrep solution below won't work. Need to use "procps -wwFAH", grep
|
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
|
||||||
# TODO: the script name, and extract the process ID from it.
|
|
||||||
fn_log_warn "Cygwin only: Previous backup task has either been interrupted or it might still be active, but there is currently no check for this. Assuming that the task was simply interrupted."
|
# 2. Get the command for the process currently running under that PID and look for our script name
|
||||||
|
RUNNINGCMD="$(procps -wwfo cmd -p $RUNNINGPID --no-headers | grep "$APPNAME")"
|
||||||
|
|
||||||
|
# 3. Grab the exit code from grep (0=found, 1=not found)
|
||||||
|
GREPCODE=$?
|
||||||
|
|
||||||
|
# 4. if found, assume backup is still running
|
||||||
|
if [ "$GREPCODE" = 0 ]; then
|
||||||
|
fn_log_error "Previous backup task is still active - aborting (command: $RUNNINGCMD)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
|
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
|
||||||
if [ "$RUNNINGPID" = "$(pgrep "$APPNAME")" ]; then
|
if [ "$RUNNINGPID" = "$(pgrep "$APPNAME")" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user