mirror of
https://github.com/deajan/obackup.git
synced 2025-01-12 15:13:53 +01:00
Added instance run check.
This commit is contained in:
parent
6eea38afdf
commit
192e1d2f65
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-pre
|
PROGRAM_VERSION=2.0-pre
|
||||||
PROGRAM_BUILD=2016030102
|
PROGRAM_BUILD=2016030301
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
## FUNC_BUILD=2016021803
|
## FUNC_BUILD=2016021803
|
||||||
@ -1019,6 +1019,10 @@ function TrapQuit {
|
|||||||
exitcode=0
|
exitcode=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
rm -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
KillChilds $$ > /dev/null 2>&1
|
KillChilds $$ > /dev/null 2>&1
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
}
|
}
|
||||||
@ -1096,6 +1100,20 @@ function CheckCurrentConfig {
|
|||||||
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckRunningInstances {
|
||||||
|
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
pid=$(cat "$RUN_DIR/$PROGRAM.$INSTANCE_ID")
|
||||||
|
if ps aux | awk '{print $2}' | grep $pid > /dev/null; then
|
||||||
|
Logger "Another instance [$INSTANCE_ID] of obackup is already running." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $SCRIPT_PID > "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
}
|
||||||
|
|
||||||
function _ListDatabasesLocal {
|
function _ListDatabasesLocal {
|
||||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
@ -2304,6 +2322,7 @@ fi
|
|||||||
GetLocalOS
|
GetLocalOS
|
||||||
InitLocalOSSettings
|
InitLocalOSSettings
|
||||||
CheckEnvironment
|
CheckEnvironment
|
||||||
|
CheckRunningInstances
|
||||||
PreInit
|
PreInit
|
||||||
Init
|
Init
|
||||||
PostInit
|
PostInit
|
||||||
|
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-pre
|
PROGRAM_VERSION=2.0-pre
|
||||||
PROGRAM_BUILD=2016030102
|
PROGRAM_BUILD=2016030301
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
source "./ofunctions.sh"
|
source "./ofunctions.sh"
|
||||||
@ -50,6 +50,10 @@ function TrapQuit {
|
|||||||
exitcode=0
|
exitcode=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
rm -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
KillChilds $$ > /dev/null 2>&1
|
KillChilds $$ > /dev/null 2>&1
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
}
|
}
|
||||||
@ -127,6 +131,20 @@ function CheckCurrentConfig {
|
|||||||
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckRunningInstances {
|
||||||
|
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
pid=$(cat "$RUN_DIR/$PROGRAM.$INSTANCE_ID")
|
||||||
|
if ps aux | awk '{print $2}' | grep $pid > /dev/null; then
|
||||||
|
Logger "Another instance [$INSTANCE_ID] of obackup is already running." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $SCRIPT_PID > "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
}
|
||||||
|
|
||||||
function _ListDatabasesLocal {
|
function _ListDatabasesLocal {
|
||||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
@ -1335,6 +1353,7 @@ fi
|
|||||||
GetLocalOS
|
GetLocalOS
|
||||||
InitLocalOSSettings
|
InitLocalOSSettings
|
||||||
CheckEnvironment
|
CheckEnvironment
|
||||||
|
CheckRunningInstances
|
||||||
PreInit
|
PreInit
|
||||||
Init
|
Init
|
||||||
PostInit
|
PostInit
|
||||||
|
20
obackup.sh
20
obackup.sh
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-pre
|
PROGRAM_VERSION=2.0-pre
|
||||||
PROGRAM_BUILD=2016030102
|
PROGRAM_BUILD=2016030301
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
## FUNC_BUILD=2016021803
|
## FUNC_BUILD=2016021803
|
||||||
@ -947,6 +947,10 @@ function TrapQuit {
|
|||||||
exitcode=0
|
exitcode=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
rm -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
KillChilds $$ > /dev/null 2>&1
|
KillChilds $$ > /dev/null 2>&1
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
}
|
}
|
||||||
@ -1022,6 +1026,19 @@ function CheckCurrentConfig {
|
|||||||
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
#TODO-v2.1: Add runtime variable tests (RSYNC_ARGS etc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckRunningInstances {
|
||||||
|
|
||||||
|
if [ -f "$RUN_DIR/$PROGRAM.$INSTANCE_ID" ]; then
|
||||||
|
pid=$(cat "$RUN_DIR/$PROGRAM.$INSTANCE_ID")
|
||||||
|
if ps aux | awk '{print $2}' | grep $pid > /dev/null; then
|
||||||
|
Logger "Another instance [$INSTANCE_ID] of obackup is already running." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $SCRIPT_PID > "$RUN_DIR/$PROGRAM.$INSTANCE_ID"
|
||||||
|
}
|
||||||
|
|
||||||
function _ListDatabasesLocal {
|
function _ListDatabasesLocal {
|
||||||
|
|
||||||
local sql_cmd=
|
local sql_cmd=
|
||||||
@ -2195,6 +2212,7 @@ fi
|
|||||||
GetLocalOS
|
GetLocalOS
|
||||||
InitLocalOSSettings
|
InitLocalOSSettings
|
||||||
CheckEnvironment
|
CheckEnvironment
|
||||||
|
CheckRunningInstances
|
||||||
PreInit
|
PreInit
|
||||||
Init
|
Init
|
||||||
PostInit
|
PostInit
|
||||||
|
Loading…
Reference in New Issue
Block a user