mirror of
https://github.com/deajan/obackup.git
synced 2024-12-27 07:53:40 +01:00
Rebuilt targets
This commit is contained in:
parent
0d4664cae0
commit
da0a45e3d3
@ -5,12 +5,12 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(C) 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.1-dev
|
PROGRAM_VERSION=2.1-dev
|
||||||
PROGRAM_BUILD=2016081806
|
PROGRAM_BUILD=2016082202
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
|
|
||||||
## FUNC_BUILD=2016081802
|
## FUNC_BUILD=2016082204
|
||||||
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||||
|
|
||||||
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
||||||
@ -193,7 +193,7 @@ function KillChilds {
|
|||||||
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
||||||
if ( [ "$self" == true ] && kill -0 $pid > /dev/null 2>&1); then
|
if ( [ "$self" == true ] && kill -0 $pid > /dev/null 2>&1); then
|
||||||
Logger "Sending SIGTERM to process [$pid]." "DEBUG"
|
Logger "Sending SIGTERM to process [$pid]." "DEBUG"
|
||||||
kill -s SIGTERM "$pid"
|
kill -s TERM "$pid"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
sleep 15
|
sleep 15
|
||||||
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
|
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
|
||||||
@ -609,28 +609,6 @@ function WaitForTaskCompletion {
|
|||||||
|
|
||||||
while [ ${#pidsArray[@]} -gt 0 ]; do
|
while [ ${#pidsArray[@]} -gt 0 ]; do
|
||||||
newPidsArray=()
|
newPidsArray=()
|
||||||
for pid in "${pidsArray[@]}"; do
|
|
||||||
if kill -0 $pid > /dev/null 2>&1; then
|
|
||||||
# Handle uninterruptible sleep state or zombies by ommiting them from running process array
|
|
||||||
#TODO(high): have this tested on *BSD, Mac & Win
|
|
||||||
pidState=$(ps -p$pid -o state= 2 > /dev/null)
|
|
||||||
if [ "$pidState" != "D" ] && [ "$pidState" != "Z" ]; then
|
|
||||||
newPidsArray+=($pid)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
wait $pid
|
|
||||||
result=$?
|
|
||||||
if [ $result -ne 0 ]; then
|
|
||||||
errorcount=$((errorcount+1))
|
|
||||||
Logger "${FUNCNAME[0]} called by [$caller_name] finished monitoring [$pid] with exitcode [$result]." "DEBUG"
|
|
||||||
if [ "$WAIT_FOR_TASK_COMPLETION" == "" ]; then
|
|
||||||
WAIT_FOR_TASK_COMPLETION="$pid:$result"
|
|
||||||
else
|
|
||||||
WAIT_FOR_TASK_COMPLETION=";$pid:$result"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
Spinner
|
Spinner
|
||||||
if [ $counting == true ]; then
|
if [ $counting == true ]; then
|
||||||
@ -670,12 +648,42 @@ function WaitForTaskCompletion {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for pid in "${pidsArray[@]}"; do
|
||||||
|
if kill -0 $pid > /dev/null 2>&1; then
|
||||||
|
# Handle uninterruptible sleep state or zombies by ommiting them from running process array (How to kill that is already dead ? :)
|
||||||
|
#TODO(high): have this tested on *BSD, Mac & Win
|
||||||
|
pidState=$(ps -p$pid -o state= 2 > /dev/null)
|
||||||
|
if [ "$pidState" != "D" ] && [ "$pidState" != "Z" ]; then
|
||||||
|
newPidsArray+=($pid)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# pid is dead, get it's exit code from wait command
|
||||||
|
wait $pid
|
||||||
|
retval=$?
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
errorcount=$((errorcount+1))
|
||||||
|
Logger "${FUNCNAME[0]} called by [$caller_name] finished monitoring [$pid] with exitcode [$result]." "DEBUG"
|
||||||
|
if [ "$WAIT_FOR_TASK_COMPLETION" == "" ]; then
|
||||||
|
WAIT_FOR_TASK_COMPLETION="$pid:$result"
|
||||||
|
else
|
||||||
|
WAIT_FOR_TASK_COMPLETION=";$pid:$result"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
pidsArray=("${newPidsArray[@]}")
|
pidsArray=("${newPidsArray[@]}")
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
done
|
done
|
||||||
|
|
||||||
Logger "${FUNCNAME[0]} ended for [$caller_name] using [$pidCount] subprocesses with [$errorcount] errors." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
Logger "${FUNCNAME[0]} ended for [$caller_name] using [$pidCount] subprocesses with [$errorcount] errors." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||||
return $errorcount
|
|
||||||
|
# Return exit code if only one process was monitored, else return number of errors
|
||||||
|
if [ $pidCount -eq 1 ] && [ $errorcount -eq 0 ]; then
|
||||||
|
return $errorcount
|
||||||
|
else
|
||||||
|
return $errorcount
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CleanUp {
|
function CleanUp {
|
||||||
@ -807,19 +815,19 @@ function GetRemoteOS {
|
|||||||
cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
Logger "Cannot Get remote OS type." "ERROR"
|
Logger "Cannot Get remote OS type." "ERROR"
|
||||||
@ -872,7 +880,7 @@ function RunLocalCommand {
|
|||||||
|
|
||||||
Logger "Running command [$command] on local host." "NOTICE"
|
Logger "Running command [$command] on local host." "NOTICE"
|
||||||
eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 &
|
eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 &
|
||||||
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
Logger "Command succeded." "NOTICE"
|
Logger "Command succeded." "NOTICE"
|
||||||
@ -907,7 +915,7 @@ function RunRemoteCommand {
|
|||||||
cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
Logger "Command succeded." "NOTICE"
|
Logger "Command succeded." "NOTICE"
|
||||||
@ -941,7 +949,7 @@ function RunBeforeHook {
|
|||||||
pids="$pids;$!"
|
pids="$pids;$!"
|
||||||
fi
|
fi
|
||||||
if [ "$pids" != "" ]; then
|
if [ "$pids" != "" ]; then
|
||||||
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,7 +968,7 @@ function RunAfterHook {
|
|||||||
pids="$pids;$!"
|
pids="$pids;$!"
|
||||||
fi
|
fi
|
||||||
if [ "$pids" != "" ]; then
|
if [ "$pids" != "" ]; then
|
||||||
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,7 +979,7 @@ function CheckConnectivityRemoteHost {
|
|||||||
|
|
||||||
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
|
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
|
||||||
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
||||||
WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping $REMOTE_HOST" "ERROR"
|
Logger "Cannot ping $REMOTE_HOST" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
@ -993,7 +1001,7 @@ function CheckConnectivity3rdPartyHosts {
|
|||||||
for i in $REMOTE_3RD_PARTY_HOSTS
|
for i in $REMOTE_3RD_PARTY_HOSTS
|
||||||
do
|
do
|
||||||
eval "$PING_CMD $i > /dev/null 2>&1" &
|
eval "$PING_CMD $i > /dev/null 2>&1" &
|
||||||
WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 180 360 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping 3rd party host $i" "NOTICE"
|
Logger "Cannot ping 3rd party host $i" "NOTICE"
|
||||||
else
|
else
|
||||||
@ -1365,9 +1373,7 @@ function TrapQuit {
|
|||||||
Logger "Backup script finished with warnings." "WARN"
|
Logger "Backup script finished with warnings." "WARN"
|
||||||
exitcode=2
|
exitcode=2
|
||||||
else
|
else
|
||||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
RunAfterHook
|
||||||
RunAfterHook
|
|
||||||
fi
|
|
||||||
CleanUp
|
CleanUp
|
||||||
Logger "Backup script finshed." "NOTICE"
|
Logger "Backup script finshed." "NOTICE"
|
||||||
exitcode=0
|
exitcode=0
|
||||||
@ -2505,7 +2511,7 @@ function Init {
|
|||||||
local hosturiandpath
|
local hosturiandpath
|
||||||
local hosturi
|
local hosturi
|
||||||
|
|
||||||
trap TrapStop SIGINT SIGQUIT SIGTERM SIGHUP
|
trap TrapStop INT QUIT TERM HUP
|
||||||
trap TrapQuit EXIT
|
trap TrapQuit EXIT
|
||||||
|
|
||||||
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
||||||
|
84
obackup.sh
84
obackup.sh
@ -5,12 +5,12 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(C) 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.1-dev
|
PROGRAM_VERSION=2.1-dev
|
||||||
PROGRAM_BUILD=2016081806
|
PROGRAM_BUILD=2016082202
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
|
|
||||||
## FUNC_BUILD=2016081802
|
## FUNC_BUILD=2016082204
|
||||||
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||||
|
|
||||||
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
||||||
@ -180,7 +180,7 @@ function KillChilds {
|
|||||||
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
||||||
if ( [ "$self" == true ] && kill -0 $pid > /dev/null 2>&1); then
|
if ( [ "$self" == true ] && kill -0 $pid > /dev/null 2>&1); then
|
||||||
Logger "Sending SIGTERM to process [$pid]." "DEBUG"
|
Logger "Sending SIGTERM to process [$pid]." "DEBUG"
|
||||||
kill -s SIGTERM "$pid"
|
kill -s TERM "$pid"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
sleep 15
|
sleep 15
|
||||||
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
|
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
|
||||||
@ -590,28 +590,6 @@ function WaitForTaskCompletion {
|
|||||||
|
|
||||||
while [ ${#pidsArray[@]} -gt 0 ]; do
|
while [ ${#pidsArray[@]} -gt 0 ]; do
|
||||||
newPidsArray=()
|
newPidsArray=()
|
||||||
for pid in "${pidsArray[@]}"; do
|
|
||||||
if kill -0 $pid > /dev/null 2>&1; then
|
|
||||||
# Handle uninterruptible sleep state or zombies by ommiting them from running process array
|
|
||||||
#TODO(high): have this tested on *BSD, Mac & Win
|
|
||||||
pidState=$(ps -p$pid -o state= 2 > /dev/null)
|
|
||||||
if [ "$pidState" != "D" ] && [ "$pidState" != "Z" ]; then
|
|
||||||
newPidsArray+=($pid)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
wait $pid
|
|
||||||
result=$?
|
|
||||||
if [ $result -ne 0 ]; then
|
|
||||||
errorcount=$((errorcount+1))
|
|
||||||
Logger "${FUNCNAME[0]} called by [$caller_name] finished monitoring [$pid] with exitcode [$result]." "DEBUG"
|
|
||||||
if [ "$WAIT_FOR_TASK_COMPLETION" == "" ]; then
|
|
||||||
WAIT_FOR_TASK_COMPLETION="$pid:$result"
|
|
||||||
else
|
|
||||||
WAIT_FOR_TASK_COMPLETION=";$pid:$result"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
Spinner
|
Spinner
|
||||||
if [ $counting == true ]; then
|
if [ $counting == true ]; then
|
||||||
@ -651,11 +629,41 @@ function WaitForTaskCompletion {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for pid in "${pidsArray[@]}"; do
|
||||||
|
if kill -0 $pid > /dev/null 2>&1; then
|
||||||
|
# Handle uninterruptible sleep state or zombies by ommiting them from running process array (How to kill that is already dead ? :)
|
||||||
|
#TODO(high): have this tested on *BSD, Mac & Win
|
||||||
|
pidState=$(ps -p$pid -o state= 2 > /dev/null)
|
||||||
|
if [ "$pidState" != "D" ] && [ "$pidState" != "Z" ]; then
|
||||||
|
newPidsArray+=($pid)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# pid is dead, get it's exit code from wait command
|
||||||
|
wait $pid
|
||||||
|
retval=$?
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
|
errorcount=$((errorcount+1))
|
||||||
|
Logger "${FUNCNAME[0]} called by [$caller_name] finished monitoring [$pid] with exitcode [$result]." "DEBUG"
|
||||||
|
if [ "$WAIT_FOR_TASK_COMPLETION" == "" ]; then
|
||||||
|
WAIT_FOR_TASK_COMPLETION="$pid:$result"
|
||||||
|
else
|
||||||
|
WAIT_FOR_TASK_COMPLETION=";$pid:$result"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
pidsArray=("${newPidsArray[@]}")
|
pidsArray=("${newPidsArray[@]}")
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
done
|
done
|
||||||
|
|
||||||
return $errorcount
|
|
||||||
|
# Return exit code if only one process was monitored, else return number of errors
|
||||||
|
if [ $pidCount -eq 1 ] && [ $errorcount -eq 0 ]; then
|
||||||
|
return $errorcount
|
||||||
|
else
|
||||||
|
return $errorcount
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CleanUp {
|
function CleanUp {
|
||||||
@ -784,19 +792,19 @@ function GetRemoteOS {
|
|||||||
cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval != 0 ]; then
|
if [ $retval != 0 ]; then
|
||||||
Logger "Cannot Get remote OS type." "ERROR"
|
Logger "Cannot Get remote OS type." "ERROR"
|
||||||
@ -848,7 +856,7 @@ function RunLocalCommand {
|
|||||||
|
|
||||||
Logger "Running command [$command] on local host." "NOTICE"
|
Logger "Running command [$command] on local host." "NOTICE"
|
||||||
eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 &
|
eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 &
|
||||||
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
Logger "Command succeded." "NOTICE"
|
Logger "Command succeded." "NOTICE"
|
||||||
@ -882,7 +890,7 @@ function RunRemoteCommand {
|
|||||||
cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
Logger "Command succeded." "NOTICE"
|
Logger "Command succeded." "NOTICE"
|
||||||
@ -915,7 +923,7 @@ function RunBeforeHook {
|
|||||||
pids="$pids;$!"
|
pids="$pids;$!"
|
||||||
fi
|
fi
|
||||||
if [ "$pids" != "" ]; then
|
if [ "$pids" != "" ]; then
|
||||||
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,7 +941,7 @@ function RunAfterHook {
|
|||||||
pids="$pids;$!"
|
pids="$pids;$!"
|
||||||
fi
|
fi
|
||||||
if [ "$pids" != "" ]; then
|
if [ "$pids" != "" ]; then
|
||||||
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,7 +951,7 @@ function CheckConnectivityRemoteHost {
|
|||||||
|
|
||||||
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
|
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
|
||||||
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
|
||||||
WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping $REMOTE_HOST" "ERROR"
|
Logger "Cannot ping $REMOTE_HOST" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
@ -964,7 +972,7 @@ function CheckConnectivity3rdPartyHosts {
|
|||||||
for i in $REMOTE_3RD_PARTY_HOSTS
|
for i in $REMOTE_3RD_PARTY_HOSTS
|
||||||
do
|
do
|
||||||
eval "$PING_CMD $i > /dev/null 2>&1" &
|
eval "$PING_CMD $i > /dev/null 2>&1" &
|
||||||
WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true $KEEP_LOGGING
|
WaitForTaskCompletion $! 180 360 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping 3rd party host $i" "NOTICE"
|
Logger "Cannot ping 3rd party host $i" "NOTICE"
|
||||||
else
|
else
|
||||||
@ -1291,9 +1299,7 @@ function TrapQuit {
|
|||||||
Logger "Backup script finished with warnings." "WARN"
|
Logger "Backup script finished with warnings." "WARN"
|
||||||
exitcode=2
|
exitcode=2
|
||||||
else
|
else
|
||||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
RunAfterHook
|
||||||
RunAfterHook
|
|
||||||
fi
|
|
||||||
CleanUp
|
CleanUp
|
||||||
Logger "Backup script finshed." "NOTICE"
|
Logger "Backup script finshed." "NOTICE"
|
||||||
exitcode=0
|
exitcode=0
|
||||||
@ -2394,7 +2400,7 @@ function Init {
|
|||||||
local hosturiandpath
|
local hosturiandpath
|
||||||
local hosturi
|
local hosturi
|
||||||
|
|
||||||
trap TrapStop SIGINT SIGQUIT SIGTERM SIGHUP
|
trap TrapStop INT QUIT TERM HUP
|
||||||
trap TrapQuit EXIT
|
trap TrapQuit EXIT
|
||||||
|
|
||||||
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
## Test if target dir is a ssh uri, and if yes, break it down it its values
|
||||||
|
Loading…
Reference in New Issue
Block a user