From 5eecb719d34a7e4dc98f07653f73747d79bc4f57 Mon Sep 17 00:00:00 2001 From: deajan Date: Sun, 19 May 2019 16:42:32 +0200 Subject: [PATCH] Rebuilt targets --- dev/debug_osync.sh | 31 ++++++++++++++++++++++++++++--- osync.sh | 31 ++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/dev/debug_osync.sh b/dev/debug_osync.sh index 8214fc5..e7a8a6c 100755 --- a/dev/debug_osync.sh +++ b/dev/debug_osync.sh @@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2019 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.3.0-pre-rc1 -PROGRAM_BUILD=2019051801 +PROGRAM_BUILD=2019051901 IS_STABLE=false CONFIG_FILE_REVISION_REQUIRED=1.3.0 @@ -5726,14 +5726,24 @@ function _SummaryFromRsyncFile { __CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG + local initiator_updates=0 + local target_updates=0 + if [ -f "$summaryFile" ]; then 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 if echo "$file" | grep -E "^<|^>|^\." > /dev/null 2>&1; then # awk removes first part of line until space, then show all others Logger "$direction $replicaPath$(echo $file | awk '{for (i=2; i>" ]; then + target_updates=$((target_updates+1)) + elif [ "$direction" == "<<" ]; then + initiator_updates=$((initiator_updates+1)) + fi fi done < "$summaryFile" + Logger "Initiator has $initiator_updates updates." "ALWAYS" + Logger "Target has $target_updates updates." "ALWAYS" fi } @@ -5744,10 +5754,20 @@ function _SummaryFromDeleteFile { __CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG + local initiator_deletes=0 + local target_deletes=0 + if [ -f "$summaryFile" ]; then while read -r file; do Logger "$direction $replicaPath$file" "ALWAYS" + if [ "$direction" == ">>" ]; then + target_deletes=$((target_deletes+1)) + elif [ "$direction" == "<<" ]; then + initiator_deletes=$((initiator_deletes+1)) + fi done < "$summaryFile" + Logger "Initiator has $initiator_deletes deletions." "ALWAYS" + Logger "Target has $target_deletes deletions.." "ALWAYS" fi } @@ -5782,19 +5802,24 @@ function LogConflicts { local subject local body + local conflicts=0 + if [ -f "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then Logger "File conflicts: INITIATOR << >> TARGET" "ALWAYS" > "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}" while read -r line; do echo "${INITIATOR[$__replicaDir]}$(echo $line | awk -F';' '{print $1}') << >> ${TARGET[$__replicaDir]}$(echo $line | awk -F';' '{print $1}')" >> "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}" + conflicts=$((conflicts+1)) done < "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ( _LOGGER_PREFIX="" Logger "$(cat "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")" "ALWAYS" ) + + Logger "There are $conflicts conflictual files." "ALWAYS" else - Logger "No conflictList file." "NOTICE" + Logger "No are no conflicatual files." "ALWAYS" fi if [ "$ALERT_CONFLICTS" == true ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then @@ -6070,7 +6095,7 @@ function Usage { echo "--silent Will run osync without any output to stdout, used for cron jobs" echo "--errors-only Output only errors (can be combined with silent or verbose)" echo "--summary Outputs a list of transferred / deleted files at the end of the run" - echo "--log-conflicts Outputs a list of conflicted files" + echo "--log-conflicts [EXPERIMENTAL] Outputs a list of conflicted files" echo "--alert-conflicts Send an email if conflictual files found (implies --log-conflicts)" echo "--verbose Increases output" echo "--stats Adds rsync transfer statistics to verbose output" diff --git a/osync.sh b/osync.sh index fd5ea8f..533aed2 100755 --- a/osync.sh +++ b/osync.sh @@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2019 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.3.0-pre-rc1 -PROGRAM_BUILD=2019051801 +PROGRAM_BUILD=2019051901 IS_STABLE=false CONFIG_FILE_REVISION_REQUIRED=1.3.0 @@ -5491,14 +5491,24 @@ function _SummaryFromRsyncFile { local direction="${3}" + local initiator_updates=0 + local target_updates=0 + if [ -f "$summaryFile" ]; then 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 if echo "$file" | grep -E "^<|^>|^\." > /dev/null 2>&1; then # awk removes first part of line until space, then show all others Logger "$direction $replicaPath$(echo $file | awk '{for (i=2; i>" ]; then + target_updates=$((target_updates+1)) + elif [ "$direction" == "<<" ]; then + initiator_updates=$((initiator_updates+1)) + fi fi done < "$summaryFile" + Logger "Initiator has $initiator_updates updates." "ALWAYS" + Logger "Target has $target_updates updates." "ALWAYS" fi } @@ -5508,10 +5518,20 @@ function _SummaryFromDeleteFile { local direction="${3}" + local initiator_deletes=0 + local target_deletes=0 + if [ -f "$summaryFile" ]; then while read -r file; do Logger "$direction $replicaPath$file" "ALWAYS" + if [ "$direction" == ">>" ]; then + target_deletes=$((target_deletes+1)) + elif [ "$direction" == "<<" ]; then + initiator_deletes=$((initiator_deletes+1)) + fi done < "$summaryFile" + Logger "Initiator has $initiator_deletes deletions." "ALWAYS" + Logger "Target has $target_deletes deletions.." "ALWAYS" fi } @@ -5544,19 +5564,24 @@ function LogConflicts { local subject local body + local conflicts=0 + if [ -f "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then Logger "File conflicts: INITIATOR << >> TARGET" "ALWAYS" > "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}" while read -r line; do echo "${INITIATOR[$__replicaDir]}$(echo $line | awk -F';' '{print $1}') << >> ${TARGET[$__replicaDir]}$(echo $line | awk -F';' '{print $1}')" >> "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}" + conflicts=$((conflicts+1)) done < "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ( _LOGGER_PREFIX="" Logger "$(cat "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")" "ALWAYS" ) + + Logger "There are $conflicts conflictual files." "ALWAYS" else - Logger "No conflictList file." "NOTICE" + Logger "No are no conflicatual files." "ALWAYS" fi if [ "$ALERT_CONFLICTS" == true ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then @@ -5829,7 +5854,7 @@ function Usage { echo "--silent Will run osync without any output to stdout, used for cron jobs" echo "--errors-only Output only errors (can be combined with silent or verbose)" echo "--summary Outputs a list of transferred / deleted files at the end of the run" - echo "--log-conflicts Outputs a list of conflicted files" + echo "--log-conflicts [EXPERIMENTAL] Outputs a list of conflicted files" echo "--alert-conflicts Send an email if conflictual files found (implies --log-conflicts)" echo "--verbose Increases output" echo "--stats Adds rsync transfer statistics to verbose output"