Rebuilt targets

This commit is contained in:
deajan 2019-05-20 11:37:55 +02:00
parent 8018871168
commit c96bdfe5ce
3 changed files with 71 additions and 47 deletions

View File

@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2019 by Orsiris de Jong" AUTHOR="(C) 2013-2019 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.3.0-pre-rc1 PROGRAM_VERSION=1.3.0-pre-rc1
PROGRAM_BUILD=2019051903 PROGRAM_BUILD=2019052004
IS_STABLE=false IS_STABLE=false
CONFIG_FILE_REVISION_REQUIRED=1.3.0 CONFIG_FILE_REVISION_REQUIRED=1.3.0
@ -1508,7 +1508,7 @@ function GetLocalOS {
localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true) localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true)
localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true) localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true)
elif [ "$LOCAL_OS" == "BusyBox" ]; then elif [ "$LOCAL_OS" == "BusyBox" ]; then
localOsVer=`ls --help 2>&1 | head -1 | cut -f2 -d' '` localOsVer=$(ls --help 2>&1 | head -1 | cut -f2 -d' ')
localOsName="BusyBox" localOsName="BusyBox"
fi fi
@ -2579,6 +2579,13 @@ function CheckCurrentConfigAll {
exit 1 exit 1
fi fi
fi fi
if [ "$SYNC_TYPE" != "" ]; then
if [ "$SYNC_TYPE" != "initiator2target" ] && [ "$SYNC_TYPE" != "target2initiator" ]; then
Logger "Bogus sync type parameter [$SYNC_TYPE]." "CRITICAL"
exit 1
fi
fi
} }
###### Osync specific functions (non shared) ###### Osync specific functions (non shared)
@ -4712,14 +4719,14 @@ function Sync {
if [ "$resumeInitiator" != "synced" ]; then if [ "$resumeInitiator" != "synced" ]; then
Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "NOTICE" Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "NOTICE"
echo $(($resumeCount+1)) > "${INITIATOR[$__resumeCount]}" echo $((resumeCount+1)) > "${INITIATOR[$__resumeCount]}"
else else
resumeInitiator="none" resumeInitiator="none"
fi fi
if [ "$resumeTarget" != "synced" ]; then if [ "$resumeTarget" != "synced" ]; then
Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "NOTICE" Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "NOTICE"
echo $(($resumeCount+1)) > "${INITIATOR[$__resumeCount]}" echo $((resumeCount+1)) > "${INITIATOR[$__resumeCount]}"
else else
resumeTarget="none" resumeTarget="none"
fi fi
@ -5726,9 +5733,6 @@ function _SummaryFromRsyncFile {
__CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG
INITIATOR_UPDATES_COUNT=0
TARGET_UPDATES_COUNT=0
if [ -f "$summaryFile" ]; then if [ -f "$summaryFile" ]; then
while read -r file; do while read -r file; do
# grep -E "^<|^>|^\." = Remove all lines that do not begin with <, > or . to deal with a bizarre bug involving rsync 3.0.6 / CentOS 6 and --skip-compress showing 'adding zip' line for every skipped compressed extension # grep -E "^<|^>|^\." = Remove all lines that do not begin with <, > or . to deal with a bizarre bug involving rsync 3.0.6 / CentOS 6 and --skip-compress showing 'adding zip' line for every skipped compressed extension
@ -5752,9 +5756,6 @@ function _SummaryFromDeleteFile {
__CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG
INITIATOR_DELETES_COUNT=0
TARGET_DELETES_COUNT=0
if [ -f "$summaryFile" ]; then if [ -f "$summaryFile" ]; then
while read -r file; do while read -r file; do
Logger "$direction $replicaPath$file" "ALWAYS" Logger "$direction $replicaPath$file" "ALWAYS"
@ -6117,6 +6118,7 @@ function Usage {
echo "--remote-token=\"\" When using ssh filter protection, you must specify the remote token set in ssh_filter.sh" echo "--remote-token=\"\" When using ssh filter protection, you must specify the remote token set in ssh_filter.sh"
echo "--instance-id=\"\" Optional sync task name to identify this synchronization task when using multiple targets" echo "--instance-id=\"\" Optional sync task name to identify this synchronization task when using multiple targets"
echo "--skip-deletion=\"\" You may skip deletion propagation on initiator or target. Valid values: initiator target initiator,target" echo "--skip-deletion=\"\" You may skip deletion propagation on initiator or target. Valid values: initiator target initiator,target"
echo "--sync-type=\"\" Allows osync to run in unidirectional sync mode. Valid values: initiator2target, target2initiator"
echo "--destination-mails=\"\" Double quoted list of space separated email addresses to send alerts to" echo "--destination-mails=\"\" Double quoted list of space separated email addresses to send alerts to"
echo "" echo ""
echo "Additionaly, you may set most osync options at runtime. eg:" echo "Additionaly, you may set most osync options at runtime. eg:"
@ -6263,6 +6265,12 @@ if [ "$MAX_WAIT" == "" ]; then
MAX_WAIT=7200 MAX_WAIT=7200
fi fi
# Global counters for --summary
INITIATOR_UPDATES_COUNT=0
TARGET_UPDATES_COUNT=0
INITIATOR_DELETES_COUNT=0
TARGET_DELETES_COUNT=0
function GetCommandlineArguments { function GetCommandlineArguments {
local isFirstArgument=true local isFirstArgument=true
@ -6271,8 +6279,8 @@ function GetCommandlineArguments {
Usage Usage
fi fi
for i in "$@"; do for i in "${@}"; do
case $i in case "$i" in
--dry) --dry)
_DRYRUN=true _DRYRUN=true
opts=$opts" --dry" opts=$opts" --dry"
@ -6305,30 +6313,34 @@ function GetCommandlineArguments {
Usage Usage
;; ;;
--initiator=*) --initiator=*)
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$((_QUICK_SYNC + 1))
INITIATOR_SYNC_DIR=${i##*=} INITIATOR_SYNC_DIR="${i##*=}"
opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\"" opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\""
;; ;;
--target=*) --target=*)
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$((_QUICK_SYNC + 1))
TARGET_SYNC_DIR=${i##*=} TARGET_SYNC_DIR="${i##*=}"
opts=$opts" --target=\"$TARGET_SYNC_DIR\"" opts=$opts" --target=\"$TARGET_SYNC_DIR\""
;; ;;
--rsakey=*) --rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=} SSH_RSA_PRIVATE_KEY="${i##*=}"
opts=$opts" --rsakey=\"$SSH_RSA_PRIVATE_KEY\"" opts=$opts" --rsakey=\"$SSH_RSA_PRIVATE_KEY\""
;; ;;
--password-file=*) --password-file=*)
SSH_PASSWORD_FILE=${i##*=} SSH_PASSWORD_FILE="${i##*=}"
opts=$opts" --password-file=\"$SSH_PASSWORD_FILE\"" opts=$opts" --password-file=\"$SSH_PASSWORD_FILE\""
;; ;;
--instance-id=*) --instance-id=*)
INSTANCE_ID=${i##*=} INSTANCE_ID="${i##*=}"
opts=$opts" --instance-id=\"$INSTANCE_ID\"" opts=$opts" --instance-id=\"$INSTANCE_ID\""
;; ;;
--skip-deletion=*) --skip-deletion=*)
opts=$opts" --skip-deletion=\"${i##*=}\"" opts=$opts" --skip-deletion=\"${i##*=}\""
SKIP_DELETION=${i##*=} SKIP_DELETION="${i##*=}"
;;
--sync-type=*)
opts=$opts" --sync-type=\"${i##*=}\""
SYNC_TYPE="${i##*=}"
;; ;;
--on-changes) --on-changes)
_SYNC_ON_CHANGES="initiator" _SYNC_ON_CHANGES="initiator"
@ -6373,10 +6385,10 @@ function GetCommandlineArguments {
_LOGGER_PREFIX="" _LOGGER_PREFIX=""
;; ;;
--destination-mails=*) --destination-mails=*)
DESTINATION_MAILS=${i##*=} DESTINATION_MAILS="${i##*=}"
;; ;;
--remote-token=*) --remote-token=*)
_REMOTE_TOKEN=${i##*=} _REMOTE_TOKEN="${i##*=}"
;; ;;
*) *)
if [ $isFirstArgument == false ]; then if [ $isFirstArgument == false ]; then
@ -6392,7 +6404,7 @@ function GetCommandlineArguments {
opts="${opts# *}" opts="${opts# *}"
} }
GetCommandlineArguments "$@" GetCommandlineArguments "${@}"
## Here we set default options for quicksync tasks when no configuration file is provided. ## Here we set default options for quicksync tasks when no configuration file is provided.
if [ $_QUICK_SYNC -eq 2 ]; then if [ $_QUICK_SYNC -eq 2 ]; then

View File

@ -579,7 +579,7 @@ function GetLocalOS {
localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true) localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true)
localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true) localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true)
elif [ "$LOCAL_OS" == "BusyBox" ]; then elif [ "$LOCAL_OS" == "BusyBox" ]; then
localOsVer=`ls --help 2>&1 | head -1 | cut -f2 -d' '` localOsVer=$(ls --help 2>&1 | head -1 | cut -f2 -d' ')
localOsName="BusyBox" localOsName="BusyBox"
fi fi

View File

@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2019 by Orsiris de Jong" AUTHOR="(C) 2013-2019 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.3.0-pre-rc1 PROGRAM_VERSION=1.3.0-pre-rc1
PROGRAM_BUILD=2019051903 PROGRAM_BUILD=2019052004
IS_STABLE=false IS_STABLE=false
CONFIG_FILE_REVISION_REQUIRED=1.3.0 CONFIG_FILE_REVISION_REQUIRED=1.3.0
@ -1432,7 +1432,7 @@ function GetLocalOS {
localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true) localOsName=$(GetConfFileValue "/etc/os-release" "NAME" true)
localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true) localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION" true)
elif [ "$LOCAL_OS" == "BusyBox" ]; then elif [ "$LOCAL_OS" == "BusyBox" ]; then
localOsVer=`ls --help 2>&1 | head -1 | cut -f2 -d' '` localOsVer=$(ls --help 2>&1 | head -1 | cut -f2 -d' ')
localOsName="BusyBox" localOsName="BusyBox"
fi fi
@ -2427,6 +2427,13 @@ function CheckCurrentConfigAll {
exit 1 exit 1
fi fi
fi fi
if [ "$SYNC_TYPE" != "" ]; then
if [ "$SYNC_TYPE" != "initiator2target" ] && [ "$SYNC_TYPE" != "target2initiator" ]; then
Logger "Bogus sync type parameter [$SYNC_TYPE]." "CRITICAL"
exit 1
fi
fi
} }
###### Osync specific functions (non shared) ###### Osync specific functions (non shared)
@ -4502,14 +4509,14 @@ function Sync {
if [ "$resumeInitiator" != "synced" ]; then if [ "$resumeInitiator" != "synced" ]; then
Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "NOTICE" Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "NOTICE"
echo $(($resumeCount+1)) > "${INITIATOR[$__resumeCount]}" echo $((resumeCount+1)) > "${INITIATOR[$__resumeCount]}"
else else
resumeInitiator="none" resumeInitiator="none"
fi fi
if [ "$resumeTarget" != "synced" ]; then if [ "$resumeTarget" != "synced" ]; then
Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "NOTICE" Logger "Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "NOTICE"
echo $(($resumeCount+1)) > "${INITIATOR[$__resumeCount]}" echo $((resumeCount+1)) > "${INITIATOR[$__resumeCount]}"
else else
resumeTarget="none" resumeTarget="none"
fi fi
@ -5491,9 +5498,6 @@ function _SummaryFromRsyncFile {
local direction="${3}" local direction="${3}"
INITIATOR_UPDATES_COUNT=0
TARGET_UPDATES_COUNT=0
if [ -f "$summaryFile" ]; then if [ -f "$summaryFile" ]; then
while read -r file; do while read -r file; do
# grep -E "^<|^>|^\." = Remove all lines that do not begin with <, > or . to deal with a bizarre bug involving rsync 3.0.6 / CentOS 6 and --skip-compress showing 'adding zip' line for every skipped compressed extension # grep -E "^<|^>|^\." = Remove all lines that do not begin with <, > or . to deal with a bizarre bug involving rsync 3.0.6 / CentOS 6 and --skip-compress showing 'adding zip' line for every skipped compressed extension
@ -5516,9 +5520,6 @@ function _SummaryFromDeleteFile {
local direction="${3}" local direction="${3}"
INITIATOR_DELETES_COUNT=0
TARGET_DELETES_COUNT=0
if [ -f "$summaryFile" ]; then if [ -f "$summaryFile" ]; then
while read -r file; do while read -r file; do
Logger "$direction $replicaPath$file" "ALWAYS" Logger "$direction $replicaPath$file" "ALWAYS"
@ -5876,6 +5877,7 @@ function Usage {
echo "--remote-token=\"\" When using ssh filter protection, you must specify the remote token set in ssh_filter.sh" echo "--remote-token=\"\" When using ssh filter protection, you must specify the remote token set in ssh_filter.sh"
echo "--instance-id=\"\" Optional sync task name to identify this synchronization task when using multiple targets" echo "--instance-id=\"\" Optional sync task name to identify this synchronization task when using multiple targets"
echo "--skip-deletion=\"\" You may skip deletion propagation on initiator or target. Valid values: initiator target initiator,target" echo "--skip-deletion=\"\" You may skip deletion propagation on initiator or target. Valid values: initiator target initiator,target"
echo "--sync-type=\"\" Allows osync to run in unidirectional sync mode. Valid values: initiator2target, target2initiator"
echo "--destination-mails=\"\" Double quoted list of space separated email addresses to send alerts to" echo "--destination-mails=\"\" Double quoted list of space separated email addresses to send alerts to"
echo "" echo ""
echo "Additionaly, you may set most osync options at runtime. eg:" echo "Additionaly, you may set most osync options at runtime. eg:"
@ -6021,6 +6023,12 @@ if [ "$MAX_WAIT" == "" ]; then
MAX_WAIT=7200 MAX_WAIT=7200
fi fi
# Global counters for --summary
INITIATOR_UPDATES_COUNT=0
TARGET_UPDATES_COUNT=0
INITIATOR_DELETES_COUNT=0
TARGET_DELETES_COUNT=0
function GetCommandlineArguments { function GetCommandlineArguments {
local isFirstArgument=true local isFirstArgument=true
@ -6029,8 +6037,8 @@ function GetCommandlineArguments {
Usage Usage
fi fi
for i in "$@"; do for i in "${@}"; do
case $i in case "$i" in
--dry) --dry)
_DRYRUN=true _DRYRUN=true
opts=$opts" --dry" opts=$opts" --dry"
@ -6063,30 +6071,34 @@ function GetCommandlineArguments {
Usage Usage
;; ;;
--initiator=*) --initiator=*)
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$((_QUICK_SYNC + 1))
INITIATOR_SYNC_DIR=${i##*=} INITIATOR_SYNC_DIR="${i##*=}"
opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\"" opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\""
;; ;;
--target=*) --target=*)
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$((_QUICK_SYNC + 1))
TARGET_SYNC_DIR=${i##*=} TARGET_SYNC_DIR="${i##*=}"
opts=$opts" --target=\"$TARGET_SYNC_DIR\"" opts=$opts" --target=\"$TARGET_SYNC_DIR\""
;; ;;
--rsakey=*) --rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=} SSH_RSA_PRIVATE_KEY="${i##*=}"
opts=$opts" --rsakey=\"$SSH_RSA_PRIVATE_KEY\"" opts=$opts" --rsakey=\"$SSH_RSA_PRIVATE_KEY\""
;; ;;
--password-file=*) --password-file=*)
SSH_PASSWORD_FILE=${i##*=} SSH_PASSWORD_FILE="${i##*=}"
opts=$opts" --password-file=\"$SSH_PASSWORD_FILE\"" opts=$opts" --password-file=\"$SSH_PASSWORD_FILE\""
;; ;;
--instance-id=*) --instance-id=*)
INSTANCE_ID=${i##*=} INSTANCE_ID="${i##*=}"
opts=$opts" --instance-id=\"$INSTANCE_ID\"" opts=$opts" --instance-id=\"$INSTANCE_ID\""
;; ;;
--skip-deletion=*) --skip-deletion=*)
opts=$opts" --skip-deletion=\"${i##*=}\"" opts=$opts" --skip-deletion=\"${i##*=}\""
SKIP_DELETION=${i##*=} SKIP_DELETION="${i##*=}"
;;
--sync-type=*)
opts=$opts" --sync-type=\"${i##*=}\""
SYNC_TYPE="${i##*=}"
;; ;;
--on-changes) --on-changes)
_SYNC_ON_CHANGES="initiator" _SYNC_ON_CHANGES="initiator"
@ -6131,10 +6143,10 @@ function GetCommandlineArguments {
_LOGGER_PREFIX="" _LOGGER_PREFIX=""
;; ;;
--destination-mails=*) --destination-mails=*)
DESTINATION_MAILS=${i##*=} DESTINATION_MAILS="${i##*=}"
;; ;;
--remote-token=*) --remote-token=*)
_REMOTE_TOKEN=${i##*=} _REMOTE_TOKEN="${i##*=}"
;; ;;
*) *)
if [ $isFirstArgument == false ]; then if [ $isFirstArgument == false ]; then
@ -6150,7 +6162,7 @@ function GetCommandlineArguments {
opts="${opts# *}" opts="${opts# *}"
} }
GetCommandlineArguments "$@" GetCommandlineArguments "${@}"
## Here we set default options for quicksync tasks when no configuration file is provided. ## Here we set default options for quicksync tasks when no configuration file is provided.
if [ $_QUICK_SYNC -eq 2 ]; then if [ $_QUICK_SYNC -eq 2 ]; then