Rebuilt targets

This commit is contained in:
deajan 2016-11-17 13:43:03 +01:00
parent 432919b3ae
commit 2da38fd0fa
3 changed files with 441 additions and 395 deletions

View File

@ -3,11 +3,11 @@
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1.4 PROGRAM_VERSION=1.1.5
PROGRAM_BUILD=2016090201 PROGRAM_BUILD=2016111701
IS_STABLE=yes IS_STABLE=yes
## FUNC_BUILD=2016071902-d ## FUNC_BUILD=2016071902-g
## 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
@ -123,14 +123,20 @@ function Logger {
if [ "$level" == "CRITICAL" ]; then if [ "$level" == "CRITICAL" ]; then
_Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value"
ERROR_ALERT=1 ERROR_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
return return
elif [ "$level" == "ERROR" ]; then elif [ "$level" == "ERROR" ]; then
_Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value"
ERROR_ALERT=1 ERROR_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
return return
elif [ "$level" == "WARN" ]; then elif [ "$level" == "WARN" ]; then
_Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value"
WARN_ALERT=1 WARN_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.warn.$SCRIPT_PID"
return return
elif [ "$level" == "NOTICE" ]; then elif [ "$level" == "NOTICE" ]; then
_Logger "$prefix$value" _Logger "$prefix$value"
@ -1011,7 +1017,7 @@ function RsyncPatternsAdd {
local pattern="${2}" local pattern="${2}"
__CheckArguments 2 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 2 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
local rest= local rest
# Disable globbing so wildcards from exclusions do not get expanded # Disable globbing so wildcards from exclusions do not get expanded
set -f set -f
@ -1055,20 +1061,29 @@ function RsyncPatterns {
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
if [ "$RSYNC_PATTERN_FIRST" == "exclude" ]; then if [ "$RSYNC_PATTERN_FIRST" == "exclude" ]; then
if [ "$RSYNC_EXCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN" RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN"
fi
if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM" RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM"
fi fi
if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
fi
if [ "$RSYNC_INCLUDE_FROM" != "" ]; then if [ "$RSYNC_INCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM" RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM"
fi fi
elif [ "$RSYNC_PATTERN_FIRST" == "include" ]; then # Use default include first for quicksync runs
elif [ "$RSYNC_PATTERN_FIRST" == "include" ] || [ "$_QUICK_SYNC" == "2" ]; then
if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN" RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN"
fi
if [ "$RSYNC_INCLUDE_FROM" != "" ]; then if [ "$RSYNC_INCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM" RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM"
fi fi
if [ "$RSYNC_EXCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN" RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN"
fi
if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM" RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM"
fi fi
@ -1276,6 +1291,14 @@ function TrapStop {
function TrapQuit { function TrapQuit {
local exitcode= local exitcode=
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID" ]; then
WARN_ALERT=1
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID" ]; then
ERROR_ALERT=1
fi
if [ $ERROR_ALERT -ne 0 ]; then if [ $ERROR_ALERT -ne 0 ]; then
UnlockReplicas UnlockReplicas
if [ "$_DEBUG" != "yes" ] if [ "$_DEBUG" != "yes" ]
@ -1627,7 +1650,7 @@ function _CheckLocksRemote {
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]} WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
if [ $? != 0 ]; then if [ $? == 0 ]; then
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
lockfile_content=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID) lockfile_content=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)
else else
@ -2308,8 +2331,6 @@ function Sync {
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
Logger "Starting synchronization task." "NOTICE" Logger "Starting synchronization task." "NOTICE"
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
if [ -f "${INITIATOR[7]}" ] && [ "$RESUME_SYNC" != "no" ]; then if [ -f "${INITIATOR[7]}" ] && [ "$RESUME_SYNC" != "no" ]; then
resume_sync=$(cat "${INITIATOR[7]}") resume_sync=$(cat "${INITIATOR[7]}")
@ -2711,14 +2732,12 @@ function Init {
fi fi
## Add Rsync include / exclude patterns ## Add Rsync include / exclude patterns
if [ $_QUICK_SYNC -lt 2 ]; then
RsyncPatterns RsyncPatterns
fi
## Conflict options ## Conflict options
if [ "$CONFLICT_BACKUP" != "no" ]; then if [ "$CONFLICT_BACKUP" != "no" ]; then
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[1]}${INITIATOR[4]}\"" INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[4]}\""
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[1]}${TARGET[4]}\"" TARGET_BACKUP="--backup --backup-dir=\"${TARGET[4]}\""
if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then
INITIATOR_BACKUP="$INITIATOR_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)" INITIATOR_BACKUP="$INITIATOR_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
TARGET_BACKUP="$TARGET_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)" TARGET_BACKUP="$TARGET_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
@ -2965,6 +2984,10 @@ opts="${opts# *}"
HARD_MAX_EXEC_TIME=0 HARD_MAX_EXEC_TIME=0
fi fi
if [ "$PATH_SEPARATOR_CHAR" == "" ]; then
PATH_SEPARATOR_CHAR=";"
fi
MIN_WAIT=30 MIN_WAIT=30
REMOTE_OPERATION=no REMOTE_OPERATION=no
else else

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PROGRAM=osync PROGRAM=osync
PROGRAM_VERSION=1.1.4 PROGRAM_VERSION=1.1.5
PROGRAM_BINARY=$PROGRAM".sh" PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh" PROGRAM_BATCH=$PROGRAM"-batch.sh"
SCRIPT_BUILD=2016082902 SCRIPT_BUILD=2016082902

View File

@ -3,11 +3,11 @@
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1.4 PROGRAM_VERSION=1.1.5
PROGRAM_BUILD=2016090201 PROGRAM_BUILD=2016111701
IS_STABLE=yes IS_STABLE=yes
## FUNC_BUILD=2016071902-d ## FUNC_BUILD=2016071902-g
## 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
@ -118,14 +118,20 @@ function Logger {
if [ "$level" == "CRITICAL" ]; then if [ "$level" == "CRITICAL" ]; then
_Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value"
ERROR_ALERT=1 ERROR_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
return return
elif [ "$level" == "ERROR" ]; then elif [ "$level" == "ERROR" ]; then
_Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value"
ERROR_ALERT=1 ERROR_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
return return
elif [ "$level" == "WARN" ]; then elif [ "$level" == "WARN" ]; then
_Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value" _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value"
WARN_ALERT=1 WARN_ALERT=1
# ERROR_ALERT / WARN_ALERT isn't set in main when Logger is called from a su$
echo "1" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.warn.$SCRIPT_PID"
return return
elif [ "$level" == "NOTICE" ]; then elif [ "$level" == "NOTICE" ]; then
_Logger "$prefix$value" _Logger "$prefix$value"
@ -943,7 +949,7 @@ function RsyncPatternsAdd {
local pattern_type="${1}" # exclude or include local pattern_type="${1}" # exclude or include
local pattern="${2}" local pattern="${2}"
local rest= local rest
# Disable globbing so wildcards from exclusions do not get expanded # Disable globbing so wildcards from exclusions do not get expanded
set -f set -f
@ -985,20 +991,29 @@ function RsyncPatternsFromAdd {
function RsyncPatterns { function RsyncPatterns {
if [ "$RSYNC_PATTERN_FIRST" == "exclude" ]; then if [ "$RSYNC_PATTERN_FIRST" == "exclude" ]; then
if [ "$RSYNC_EXCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN" RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN"
fi
if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM" RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM"
fi fi
if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
fi
if [ "$RSYNC_INCLUDE_FROM" != "" ]; then if [ "$RSYNC_INCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM" RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM"
fi fi
elif [ "$RSYNC_PATTERN_FIRST" == "include" ]; then # Use default include first for quicksync runs
elif [ "$RSYNC_PATTERN_FIRST" == "include" ] || [ "$_QUICK_SYNC" == "2" ]; then
if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN" RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN"
fi
if [ "$RSYNC_INCLUDE_FROM" != "" ]; then if [ "$RSYNC_INCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM" RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM"
fi fi
if [ "$RSYNC_EXCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN" RsyncPatternsAdd "exclude" "$RSYNC_EXCLUDE_PATTERN"
fi
if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then if [ "$RSYNC_EXCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM" RsyncPatternsFromAdd "exclude" "$RSYNC_EXCLUDE_FROM"
fi fi
@ -1202,6 +1217,14 @@ function TrapStop {
function TrapQuit { function TrapQuit {
local exitcode= local exitcode=
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID" ]; then
WARN_ALERT=1
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID" ]; then
ERROR_ALERT=1
fi
if [ $ERROR_ALERT -ne 0 ]; then if [ $ERROR_ALERT -ne 0 ]; then
UnlockReplicas UnlockReplicas
if [ "$_DEBUG" != "yes" ] if [ "$_DEBUG" != "yes" ]
@ -1537,7 +1560,7 @@ function _CheckLocksRemote {
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]} WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
if [ $? != 0 ]; then if [ $? == 0 ]; then
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
lockfile_content=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID) lockfile_content=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)
else else
@ -2204,8 +2227,6 @@ function Sync {
local resume_sync= local resume_sync=
Logger "Starting synchronization task." "NOTICE" Logger "Starting synchronization task." "NOTICE"
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
if [ -f "${INITIATOR[7]}" ] && [ "$RESUME_SYNC" != "no" ]; then if [ -f "${INITIATOR[7]}" ] && [ "$RESUME_SYNC" != "no" ]; then
resume_sync=$(cat "${INITIATOR[7]}") resume_sync=$(cat "${INITIATOR[7]}")
@ -2603,14 +2624,12 @@ function Init {
fi fi
## Add Rsync include / exclude patterns ## Add Rsync include / exclude patterns
if [ $_QUICK_SYNC -lt 2 ]; then
RsyncPatterns RsyncPatterns
fi
## Conflict options ## Conflict options
if [ "$CONFLICT_BACKUP" != "no" ]; then if [ "$CONFLICT_BACKUP" != "no" ]; then
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[1]}${INITIATOR[4]}\"" INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[4]}\""
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[1]}${TARGET[4]}\"" TARGET_BACKUP="--backup --backup-dir=\"${TARGET[4]}\""
if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then
INITIATOR_BACKUP="$INITIATOR_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)" INITIATOR_BACKUP="$INITIATOR_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
TARGET_BACKUP="$TARGET_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)" TARGET_BACKUP="$TARGET_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
@ -2854,6 +2873,10 @@ opts="${opts# *}"
HARD_MAX_EXEC_TIME=0 HARD_MAX_EXEC_TIME=0
fi fi
if [ "$PATH_SEPARATOR_CHAR" == "" ]; then
PATH_SEPARATOR_CHAR=";"
fi
MIN_WAIT=30 MIN_WAIT=30
REMOTE_OPERATION=no REMOTE_OPERATION=no
else else