2
0
mirror of https://github.com/deajan/osync synced 2024-11-15 12:12:56 +00:00

Rendered associative like arrays bash 3 compatible

This commit is contained in:
deajan 2016-08-30 12:19:12 +02:00
parent f5698c6037
commit 90d16862d2

View File

@ -4,7 +4,7 @@ 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.2-beta PROGRAM_VERSION=1.2-beta
PROGRAM_BUILD=2016083001 PROGRAM_BUILD=2016083002
IS_STABLE=no IS_STABLE=no
# Execution order #__WITH_PARANOIA_DEBUG # Execution order #__WITH_PARANOIA_DEBUG
@ -228,23 +228,23 @@ function CheckReplicaPaths {
local pids local pids
# Use direct comparaison before having a portable realpath implementation # Use direct comparaison before having a portable realpath implementation
#INITIATOR_SYNC_DIR_CANN=$(realpath "${INITIATOR[replicaDir]}") #TODO(verylow): investigate realpath & readlink issues on MSYS and busybox here #INITIATOR_SYNC_DIR_CANN=$(realpath "${INITIATOR[$__replicaDir]}") #TODO(verylow): investigate realpath & readlink issues on MSYS and busybox here
#TARGET_SYNC_DIR_CANN=$(realpath "${TARGET[replicaDir]}) #TARGET_SYNC_DIR_CANN=$(realpath "${TARGET[$__replicaDir]})
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "${INITIATOR[replicaDir]}" == "${TARGET[replicaDir]}" ]; then if [ "${INITIATOR[$__replicaDir]}" == "${TARGET[$__replicaDir]}" ]; then
Logger "Initiator and target path [${INITIATOR[replicaDir]}] cannot be the same." "CRITICAL" Logger "Initiator and target path [${INITIATOR[$__replicaDir]}] cannot be the same." "CRITICAL"
exit 1 exit 1
fi fi
fi fi
_CheckReplicaPathsLocal "${INITIATOR[replicaDir]}" & _CheckReplicaPathsLocal "${INITIATOR[$__replicaDir]}" &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_CheckReplicaPathsLocal "${TARGET[replicaDir]}" & _CheckReplicaPathsLocal "${TARGET[$__replicaDir]}" &
pids="$pids;$!" pids="$pids;$!"
else else
_CheckReplicaPathsRemote "${TARGET[replicaDir]}" & _CheckReplicaPathsRemote "${TARGET[$__replicaDir]}" &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} false $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} false $KEEP_LOGGING
@ -304,13 +304,13 @@ function CheckDiskSpace {
return 0 return 0
fi fi
_CheckDiskSpaceLocal "${INITIATOR[replicaDir]}" & _CheckDiskSpaceLocal "${INITIATOR[$__replicaDir]}" &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_CheckDiskSpaceLocal "${TARGET[replicaDir]}" & _CheckDiskSpaceLocal "${TARGET[$__replicaDir]}" &
pids="$pids;$!" pids="$pids;$!"
else else
_CheckDiskSpaceRemote "${TARGET[replicaDir]}" & _CheckDiskSpaceRemote "${TARGET[$__replicaDir]}" &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -355,13 +355,13 @@ function CreateStateDirs {
local pids local pids
_CreateStateDirsLocal "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}" & _CreateStateDirsLocal "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}" &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_CreateStateDirsLocal "${TARGET[replicaDir]}${TARGET[stateDir]}" & _CreateStateDirsLocal "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}" &
pids="$pids;$!" pids="$pids;$!"
else else
_CreateStateDirsRemote "${TARGET[replicaDir]}${TARGET[stateDir]}" & _CreateStateDirsRemote "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}" &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -460,13 +460,13 @@ function CheckLocks {
fi fi
fi fi
_CheckLocksLocal "${INITIATOR[lockFile]}" & _CheckLocksLocal "${INITIATOR[$__lockFile]}" &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_CheckLocksLocal "${TARGET[lockFile]}" & _CheckLocksLocal "${TARGET[$__lockFile]}" &
pids="$pids;$!" pids="$pids;$!"
else else
_CheckLocksRemote "${TARGET[lockFile]}" & _CheckLocksRemote "${TARGET[$__lockFile]}" &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -520,14 +520,14 @@ function WriteLockFiles {
local pidArray local pidArray
local pid local pid
_WriteLockFilesLocal "${INITIATOR[lockFile]}" "${INITIATOR[type]}"& _WriteLockFilesLocal "${INITIATOR[$__lockFile]}" "${INITIATOR[$__type]}"&
initiatorPid="$!" initiatorPid="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_WriteLockFilesLocal "${TARGET[lockFile]}" "${TARGET[type]}" & _WriteLockFilesLocal "${TARGET[$__lockFile]}" "${TARGET[$__type]}" &
targetPid="$!" targetPid="$!"
else else
_WriteLockFilesRemote "${TARGET[lockFile]}" "${TARGET[type]}" & _WriteLockFilesRemote "${TARGET[$__lockFile]}" "${TARGET[$__type]}" &
targetPid="$!" targetPid="$!"
fi fi
@ -594,16 +594,16 @@ function UnlockReplicas {
fi fi
if [ $INITIATOR_LOCK_FILE_EXISTS == true ]; then if [ $INITIATOR_LOCK_FILE_EXISTS == true ]; then
_UnlockReplicasLocal "${INITIATOR[lockFile]}" & _UnlockReplicasLocal "${INITIATOR[$__lockFile]}" &
pids="$!" pids="$!"
fi fi
if [ $TARGET_LOCK_FILE_EXISTS == true ]; then if [ $TARGET_LOCK_FILE_EXISTS == true ]; then
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_UnlockReplicasLocal "${TARGET[lockFile]}" & _UnlockReplicasLocal "${TARGET[$__lockFile]}" &
pids="$pids;$!" pids="$pids;$!"
else else
_UnlockReplicasRemote "${TARGET[lockFile]}" & _UnlockReplicasRemote "${TARGET[$__lockFile]}" &
pids="$pids;$!" pids="$pids;$!"
fi fi
fi fi
@ -633,7 +633,7 @@ function tree_list {
escaped_replica_path=$(EscapeSpaces "$replica_path") escaped_replica_path=$(EscapeSpaces "$replica_path")
Logger "Creating $replica_type replica file list [$replica_path]." "NOTICE" Logger "Creating $replica_type replica file list [$replica_path]." "NOTICE"
if [ "$REMOTE_OPERATION" == "yes" ] && [ "$replica_type" == "${TARGET[type]}" ]; then if [ "$REMOTE_OPERATION" == "yes" ] && [ "$replica_type" == "${TARGET[$__type]}" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS -8 --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$escaped_replica_path/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID\"" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS -8 --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$escaped_replica_path/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID\""
@ -647,7 +647,7 @@ function tree_list {
retval=$? retval=$?
## Retval 24 = some files vanished while creating list ## Retval 24 = some files vanished while creating list
if ([ $retval == 0 ] || [ $retval == 24 ]) && [ -f "$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID" ]; then if ([ $retval == 0 ] || [ $retval == 24 ]) && [ -f "$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID" ]; then
mv -f "$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID" "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$tree_filename" mv -f "$RUN_DIR/$PROGRAM.$replica_type.$SCRIPT_PID" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$tree_filename"
return $? return $?
else else
Logger "Cannot create replica file list in [$replica_path]." "CRITICAL" Logger "Cannot create replica file list in [$replica_path]." "CRITICAL"
@ -667,13 +667,13 @@ function delete_list {
local cmd local cmd
Logger "Creating $replica_type replica deleted file list." "NOTICE" Logger "Creating $replica_type replica deleted file list." "NOTICE"
if [ -f "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type${INITIATOR[treeAfterFile]}_NO_SUFFIX" ]; then if [ -f "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type${INITIATOR[$__treeAfterFile]}_NO_SUFFIX" ]; then
## Same functionnality, comm is much faster than grep but is not available on every platform ## Same functionnality, comm is much faster than grep but is not available on every platform
if type comm > /dev/null 2>&1 ; then if type comm > /dev/null 2>&1 ; then
cmd="comm -23 \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type${INITIATOR[treeAfterFileNoSuffix]}\" \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$tree_file_current\" > \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_list_file\"" cmd="comm -23 \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type${INITIATOR[$__treeAfterFileNoSuffix]}\" \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$tree_file_current\" > \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_list_file\""
else else
## The || : forces the command to have a good result ## The || : forces the command to have a good result
cmd="(grep -F -x -v -f \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$tree_file_current\" \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type${INITIATOR[treeAfterFileNoSuffix]}\" || :) > \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_list_file\"" cmd="(grep -F -x -v -f \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$tree_file_current\" \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type${INITIATOR[$__treeAfterFileNoSuffix]}\" || :) > \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_list_file\""
fi fi
Logger "CMD: $cmd" "DEBUG" Logger "CMD: $cmd" "DEBUG"
@ -681,14 +681,14 @@ function delete_list {
retval=$? retval=$?
# Add delete failed file list to current delete list and then empty it # Add delete failed file list to current delete list and then empty it
if [ -f "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_failed_list_file" ]; then if [ -f "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_failed_list_file" ]; then
cat "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_failed_list_file" >> "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_list_file" cat "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_failed_list_file" >> "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_list_file"
rm -f "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_failed_list_file" rm -f "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_failed_list_file"
fi fi
return $retval return $retval
else else
touch "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_list_file" touch "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_list_file"
return $retval return $retval
fi fi
} }
@ -736,7 +736,7 @@ function _get_file_ctime_mtime_remote {
function sync_attrs { function sync_attrs {
local initiator_replica="${1}" local initiator_replica="${1}"
local target_replica="${2}" local target_replica="${2}"
local delete_list_filename="${INITIATOR[deletedListFile]}" # Contains deleted list filename, will be prefixed with replica type local delete_list_filename="${INITIATOR[$__deletedListFile]}" # Contains deleted list filename, will be prefixed with replica type
__CheckArguments 2 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 2 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
local rsync_cmd local rsync_cmd
@ -777,15 +777,15 @@ function sync_attrs {
fi fi
Logger "Getting ctimes for pending files on initiator." "NOTICE" Logger "Getting ctimes for pending files on initiator." "NOTICE"
_get_file_ctime_mtime_local "${INITIATOR[replicaDir]}" "${INITIATOR[type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" & _get_file_ctime_mtime_local "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" &
pids="$!" pids="$!"
Logger "Getting ctimes for pending files on target." "NOTICE" Logger "Getting ctimes for pending files on target." "NOTICE"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_get_file_ctime_mtime_local "${TARGET[replicaDir]}" "${TARGET[type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" & _get_file_ctime_mtime_local "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" &
pids="$pids;$!" pids="$pids;$!"
else else
_get_file_ctime_mtime_remote "${TARGET[replicaDir]}" "${TARGET[type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" & _get_file_ctime_mtime_remote "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID" &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 1800 0 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 1800 0 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -793,23 +793,23 @@ function sync_attrs {
# If target gets updated first, then sync_attr must update initiator's attrs first # If target gets updated first, then sync_attr must update initiator's attrs first
# For join, remove leading replica paths # For join, remove leading replica paths
sed -i'.tmp' "s;^${INITIATOR[replicaDir]};;g" "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[type]}.$SCRIPT_PID" sed -i'.tmp' "s;^${INITIATOR[$__replicaDir]};;g" "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[$__type]}.$SCRIPT_PID"
sed -i'.tmp' "s;^${TARGET[replicaDir]};;g" "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[type]}.$SCRIPT_PID" sed -i'.tmp' "s;^${TARGET[$__replicaDir]};;g" "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[$__type]}.$SCRIPT_PID"
if [ "$CONFLICT_PREVALANCE" == "${TARGET[type]}" ]; then if [ "$CONFLICT_PREVALANCE" == "${TARGET[$__type]}" ]; then
local source_dir="${INITIATOR[replicaDir]}" local source_dir="${INITIATOR[$__replicaDir]}"
esc_source_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}") esc_source_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
local dest_dir="${TARGET[replicaDir]}" local dest_dir="${TARGET[$__replicaDir]}"
esc_dest_dir=$(EscapeSpaces "${TARGET[replicaDir]}") esc_dest_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
local dest_replica="${TARGET[type]}" local dest_replica="${TARGET[$__type]}"
join -j 1 -t ';' -o 1.1,1.2,2.2 "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[type]}.$SCRIPT_PID" "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[type]}.$SCRIPT_PID" | awk -F';' '{if ($2 > $3) print $1}' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID" join -j 1 -t ';' -o 1.1,1.2,2.2 "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[$__type]}.$SCRIPT_PID" "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[$__type]}.$SCRIPT_PID" | awk -F';' '{if ($2 > $3) print $1}' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID"
else else
local source_dir="${TARGET[replicaDir]}" local source_dir="${TARGET[$__replicaDir]}"
esc_source_dir=$(EscapeSpaces "${TARGET[replicaDir]}") esc_source_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
local dest_dir="${INITIATOR[replicaDir]}" local dest_dir="${INITIATOR[$__replicaDir]}"
esc_dest_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}") esc_dest_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
local dest_replica="${INITIATOR[type]}" local dest_replica="${INITIATOR[$__type]}"
join -j 1 -t ';' -o 1.1,1.2,2.2 "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[type]}.$SCRIPT_PID" "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[type]}.$SCRIPT_PID" | awk -F';' '{if ($2 > $3) print $1}' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID" join -j 1 -t ';' -o 1.1,1.2,2.2 "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[$__type]}.$SCRIPT_PID" "$RUN_DIR/$PROGRAM.ctime_mtime.${INITIATOR[$__type]}.$SCRIPT_PID" | awk -F';' '{if ($2 > $3) print $1}' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID"
fi fi
if [ $(wc -l < "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID") -eq 0 ]; then if [ $(wc -l < "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID") -eq 0 ]; then
@ -824,13 +824,13 @@ function sync_attrs {
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
# No rsync args (hence no -r) because files are selected with --from-file # No rsync args (hence no -r) because files are selected with --from-file
if [ "$dest_replica" == "${INITIATOR[type]}" ]; then if [ "$dest_replica" == "${INITIATOR[$__type]}" ]; then
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${INITIATOR[type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${TARGET[type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${TARGET[$__type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &"
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${INITIATOR[type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${TARGET[type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" \"$source_dir\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${TARGET[$__type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" \"$source_dir\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &"
fi fi
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${INITIATOR[type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/${TARGET[type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" \"$source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $SYNC_OPTS --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${TARGET[$__type]}$delete_list_filename\" --files-from=\"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID\" \"$source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID 2>&1 &"
fi fi
@ -867,32 +867,32 @@ function sync_update {
local esc_dest_dir local esc_dest_dir
Logger "Updating $destination_replica replica." "NOTICE" Logger "Updating $destination_replica replica." "NOTICE"
if [ "$source_replica" == "${INITIATOR[type]}" ]; then if [ "$source_replica" == "${INITIATOR[$__type]}" ]; then
local source_dir="${INITIATOR[replicaDir]}" local source_dir="${INITIATOR[$__replicaDir]}"
local dest_dir="${TARGET[replicaDir]}" local dest_dir="${TARGET[$__replicaDir]}"
local backup_args="$TARGET_BACKUP" local backup_args="$TARGET_BACKUP"
esc_source_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}") esc_source_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
esc_dest_dir=$(EscapeSpaces "${TARGET[replicaDir]}") esc_dest_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
else else
local source_dir="${TARGET[replicaDir]}" local source_dir="${TARGET[$__replicaDir]}"
local dest_dir="${INITIATOR[replicaDir]}" local dest_dir="${INITIATOR[$__replicaDir]}"
local backup_args="$INITIATOR_BACKUP" local backup_args="$INITIATOR_BACKUP"
esc_source_dir=$(EscapeSpaces "${TARGET[replicaDir]}") esc_source_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
esc_dest_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}") esc_dest_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
fi fi
if [ "$REMOTE_OPERATION" == "yes" ]; then if [ "$REMOTE_OPERATION" == "yes" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
if [ "$source_replica" == "${INITIATOR[type]}" ]; then if [ "$source_replica" == "${INITIATOR[$__type]}" ]; then
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$source_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$destination_replica$delete_list_filename\" \"$source_dir\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$source_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$destination_replica$delete_list_filename\" \"$source_dir\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1"
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$destination_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$source_replica$delete_list_filename\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS -e \"$RSYNC_SSH_CMD\" $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$destination_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$source_replica$delete_list_filename\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1"
fi fi
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$source_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$destination_replica$delete_list_filename\" \"$source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS $RSYNC_DRY_ARG $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS $SYNC_OPTS $backup_args --exclude \"$OSYNC_DIR\" $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$source_replica$delete_list_filename\" --exclude-from=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$destination_replica$delete_list_filename\" \"$source_dir\" \"$dest_dir\" >> $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID 2>&1"
fi fi
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG" Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
eval "$rsync_cmd" eval "$rsync_cmd"
@ -956,7 +956,7 @@ function _delete_local {
fi fi
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$replica_dir$files] to deletion directory." "ERROR" Logger "Cannot move [$replica_dir$files] to deletion directory." "ERROR"
echo "$files" >> "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$deleted_failed_list_file" echo "$files" >> "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deleted_failed_list_file"
fi fi
fi fi
fi fi
@ -968,14 +968,14 @@ function _delete_local {
Logger "Deleting [$replica_dir$files]." "VERBOSE" Logger "Deleting [$replica_dir$files]." "VERBOSE"
if [ $result != 0 ]; then if [ $result != 0 ]; then
Logger "Cannot delete [$replica_dir$files]." "ERROR" Logger "Cannot delete [$replica_dir$files]." "ERROR"
echo "$files" >> "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$deleted_failed_list_file" echo "$files" >> "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deleted_failed_list_file"
fi fi
fi fi
fi fi
fi fi
previous_file="$files" previous_file="$files"
fi fi
done < "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$deleted_list_file" done < "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deleted_list_file"
} }
function _delete_remote { function _delete_remote {
@ -992,8 +992,8 @@ function _delete_remote {
## Anything beetween << ENDSSH and ENDSSH will be executed remotely ## Anything beetween << ENDSSH and ENDSSH will be executed remotely
# Additionnaly, we need to copy the deletetion list to the remote state folder # Additionnaly, we need to copy the deletetion list to the remote state folder
esc_dest_dir="$(EscapeSpaces "${TARGET[replicaDir]}${TARGET[stateDir]}")" esc_dest_dir="$(EscapeSpaces "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}")"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$deleted_list_file\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir/\" >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID 2>&1" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deleted_list_file\" $REMOTE_USER@$REMOTE_HOST:\"$esc_dest_dir/\" >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID 2>&1"
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG" Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
eval "$rsync_cmd" 2>> "$LOG_FILE" eval "$rsync_cmd" 2>> "$LOG_FILE"
if [ $? != 0 ]; then if [ $? != 0 ]; then
@ -1004,7 +1004,7 @@ function _delete_remote {
exit 1 exit 1
fi fi
$SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _DEBUG=$_DEBUG _DRYRUN=$_DRYRUN _VERBOSE=$_VERBOSE COMMAND_SUDO=$COMMAND_SUDO FILE_LIST="$(EscapeSpaces "${TARGET[replicaDir]}${TARGET[stateDir]}/$deleted_list_file")" REPLICA_DIR="$(EscapeSpaces "$replica_dir")" SOFT_DELETE=$SOFT_DELETE DELETE_DIR="$(EscapeSpaces "$deletion_dir")" FAILED_DELETE_LIST="$(EscapeSpaces "${TARGET[replicaDir]}${TARGET[stateDir]}/$deleted_failed_list_file")" 'bash -s' << 'ENDSSH' >> "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID" 2>&1 $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _DEBUG=$_DEBUG _DRYRUN=$_DRYRUN _VERBOSE=$_VERBOSE COMMAND_SUDO=$COMMAND_SUDO FILE_LIST="$(EscapeSpaces "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}/$deleted_list_file")" REPLICA_DIR="$(EscapeSpaces "$replica_dir")" SOFT_DELETE=$SOFT_DELETE DELETE_DIR="$(EscapeSpaces "$deletion_dir")" FAILED_DELETE_LIST="$(EscapeSpaces "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}/$deleted_failed_list_file")" 'bash -s' << 'ENDSSH' >> "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID" 2>&1
## The following lines are executed remotely ## The following lines are executed remotely
function _logger { function _logger {
@ -1111,8 +1111,8 @@ ENDSSH
fi fi
## Copy back the deleted failed file list ## Copy back the deleted failed file list
esc_source_file="$(EscapeSpaces "${TARGET[replicaDir]}${TARGET[stateDir]}/$deleted_failed_list_file")" esc_source_file="$(EscapeSpaces "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}/$deleted_failed_list_file")"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_file\" \"${INITIATOR[replicaDir]}${INITIATOR[stateDir]}\" > \"$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID\"" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -e \"$RSYNC_SSH_CMD\" $REMOTE_USER@$REMOTE_HOST:\"$esc_source_file\" \"${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}\" > \"$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID\""
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG" Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
eval "$rsync_cmd" 2>> "$LOG_FILE" eval "$rsync_cmd" 2>> "$LOG_FILE"
result=$? result=$?
@ -1138,24 +1138,24 @@ function deletion_propagation {
Logger "Propagating deletions to $replica_type replica." "NOTICE" Logger "Propagating deletions to $replica_type replica." "NOTICE"
if [ "$replica_type" == "${INITIATOR[type]}" ]; then if [ "$replica_type" == "${INITIATOR[$__type]}" ]; then
replica_dir="${INITIATOR[replicaDir]}" replica_dir="${INITIATOR[$__replicaDir]}"
delete_dir="${INITIATOR[deleteDir]}" delete_dir="${INITIATOR[$__deleteDir]}"
_delete_local "$replica_dir" "${TARGET[type]}$deleted_list_file" "$delete_dir" "${TARGET[type]}$deleted_failed_list_file" _delete_local "$replica_dir" "${TARGET[$__type]}$deleted_list_file" "$delete_dir" "${TARGET[$__type]}$deleted_failed_list_file"
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
Logger "Deletion on replica $replica_type failed." "CRITICAL" Logger "Deletion on replica $replica_type failed." "CRITICAL"
exit 1 exit 1
fi fi
else else
replica_dir="${TARGET[replicaDir]}" replica_dir="${TARGET[$__replicaDir]}"
delete_dir="${TARGET[deleteDir]}" delete_dir="${TARGET[$__deleteDir]}"
if [ "$REMOTE_OPERATION" == "yes" ]; then if [ "$REMOTE_OPERATION" == "yes" ]; then
_delete_remote "$replica_dir" "${INITIATOR[type]}$deleted_list_file" "$delete_dir" "${INITIATOR[type]}$deleted_failed_list_file" _delete_remote "$replica_dir" "${INITIATOR[$__type]}$deleted_list_file" "$delete_dir" "${INITIATOR[$__type]}$deleted_failed_list_file"
else else
_delete_local "$replica_dir" "${INITIATOR[type]}$deleted_list_file" "$delete_dir" "${INITIATOR[type]}$deleted_failed_list_file" _delete_local "$replica_dir" "${INITIATOR[$__type]}$deleted_list_file" "$delete_dir" "${INITIATOR[$__type]}$deleted_failed_list_file"
fi fi
retval=$? retval=$?
if [ $retval == 0 ]; then if [ $retval == 0 ]; then
@ -1200,41 +1200,41 @@ function Sync {
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
if [ "$RESUME_SYNC" != "no" ]; then if [ "$RESUME_SYNC" != "no" ]; then
if [ -f "${INITIATOR[resumeCount]}" ]; then if [ -f "${INITIATOR[$__resumeCount]}" ]; then
resumeCount=$(cat "${INITIATOR[resumeCount]}") resumeCount=$(cat "${INITIATOR[$__resumeCount]}")
else else
resumeCount=0 resumeCount=0
fi fi
if [ $resumeCount -lt $RESUME_TRY ]; then if [ $resumeCount -lt $RESUME_TRY ]; then
if [ -f "${INITIATOR[initiatorLastActionFile]}" ]; then if [ -f "${INITIATOR[$__initiatorLastActionFile]}" ]; then
resumeInitiator=$(cat "${INITIATOR[initiatorLastActionFile]}") resumeInitiator=$(cat "${INITIATOR[$__initiatorLastActionFile]}")
else else
resumeInitiator="synced" resumeInitiator="synced"
fi fi
if [ -f "${INITIATOR[targetLastActionFile]}" ]; then if [ -f "${INITIATOR[$__targetLastActionFile]}" ]; then
resumeTarget=$(cat "${INITIATOR[targetLastActionFile]}") resumeTarget=$(cat "${INITIATOR[$__targetLastActionFile]}")
else else
resumeTarget="synced" resumeTarget="synced"
fi fi
if [ "$resumeInitiator" != "synced" ]; then if [ "$resumeInitiator" != "synced" ]; then
Logger "WARNING: Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "WARN" Logger "WARNING: Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__initiatorLastActionFile]}") at task [$resumeInitiator] for initiator. [$resumeCount] previous tries." "WARN"
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 "WARNING: Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "WARN" Logger "WARNING: Trying to resume aborted execution on $($STAT_CMD "${INITIATOR[$__targetLastActionFile]}") as task [$resumeTarget] for target. [$resumeCount] previous tries." "WARN"
echo $(($resumeCount+1)) > "${INITIATOR[resumeCount]}" echo $(($resumeCount+1)) > "${INITIATOR[$__resumeCount]}"
else else
resumeTarget="none" resumeTarget="none"
fi fi
else else
Logger "Will not resume aborted execution. Too many resume tries [$resumeCount]." "WARN" Logger "Will not resume aborted execution. Too many resume tries [$resumeCount]." "WARN"
echo "0" > "${INITIATOR[resumeCount]}" echo "0" > "${INITIATOR[$__resumeCount]}"
resumeInitiator="none" resumeInitiator="none"
resumeTarget="none" resumeTarget="none"
fi fi
@ -1249,12 +1249,12 @@ function Sync {
## Step 0a & 0b ## Step 0a & 0b
if [ "$resumeInitiator" == "none" ] || [ "$resumeTarget" == "none" ] || [ "$resumeInitiator" == "${SYNC_ACTION[0]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[0]}" ]; then if [ "$resumeInitiator" == "none" ] || [ "$resumeTarget" == "none" ] || [ "$resumeInitiator" == "${SYNC_ACTION[0]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[0]}" ]; then
if [ "$resumeInitiator" == "none" ] || [ "$resumeInitiator" == "${SYNC_ACTION[0]}" ]; then if [ "$resumeInitiator" == "none" ] || [ "$resumeInitiator" == "${SYNC_ACTION[0]}" ]; then
tree_list "${INITIATOR[replicaDir]}" "${INITIATOR[type]}" "${INITIATOR[treeCurrentFile]}" & tree_list "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" "${INITIATOR[$__treeCurrentFile]}" &
initiatorPid="$!" initiatorPid="$!"
fi fi
if [ "$resumeTarget" == "none" ] || [ "$resumeTarget" == "${SYNC_ACTION[0]}" ]; then if [ "$resumeTarget" == "none" ] || [ "$resumeTarget" == "${SYNC_ACTION[0]}" ]; then
tree_list "${TARGET[replicaDir]}" "${TARGET[type]}" "${INITIATOR[treeCurrentFile]}" & tree_list "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "${INITIATOR[$__treeCurrentFile]}" &
targetPid="$!" targetPid="$!"
fi fi
@ -1266,26 +1266,26 @@ function Sync {
for pid in "${pidArray[@]}"; do for pid in "${pidArray[@]}"; do
pid=${pid%:*} pid=${pid%:*}
if [ $pid == $initiatorPid ]; then if [ $pid == $initiatorPid ]; then
echo "${SYNC_ACTION[0]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[0]}" > "${INITIATOR[$__initiatorLastActionFile]}"
initiatorFail=true initiatorFail=true
elif [ $pid == $targetPid ]; then elif [ $pid == $targetPid ]; then
echo "${SYNC_ACTION[0]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[0]}" > "${INITIATOR[$__targetLastActionFile]}"
targetFail=true targetFail=true
fi fi
done done
if [ $initiatorFail == false ]; then if [ $initiatorFail == false ]; then
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
fi fi
if [ $targetFail == false ]; then if [ $targetFail == false ]; then
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
fi fi
exit 1 exit 1
else else
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[1]}" resumeInitiator="${SYNC_ACTION[1]}"
resumeTarget="${SYNC_ACTION[1]}" resumeTarget="${SYNC_ACTION[1]}"
fi fi
@ -1294,12 +1294,12 @@ function Sync {
## Step 1a & 1b ## Step 1a & 1b
if [ "$resumeInitiator" == "${SYNC_ACTION[1]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[1]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[1]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[1]}" ]; then
if [ "$resumeInitiator" == "${SYNC_ACTION[1]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[1]}" ]; then
delete_list "${INITIATOR[type]}" "${INITIATOR[treeAfterFile]}" "${INITIATOR[treeCurrentFile]}" "${INITIATOR[deletedListFile]}" "${INITIATOR[failedDeletedListFile]}" & delete_list "${INITIATOR[$__type]}" "${INITIATOR[$__treeAfterFile]}" "${INITIATOR[$__treeCurrentFile]}" "${INITIATOR[$__deletedListFile]}" "${INITIATOR[$__failedDeletedListFile]}" &
initiatorPid="$!" initiatorPid="$!"
fi fi
if [ "$resumeTarget" == "${SYNC_ACTION[1]}" ]; then if [ "$resumeTarget" == "${SYNC_ACTION[1]}" ]; then
delete_list "${TARGET[type]}" "${INITIATOR[treeAfterFile]}" "${INITIATOR[treeCurrentFile]}" "${INITIATOR[deletedListFile]}" "${INITIATOR[failedDeletedListFile]}" & delete_list "${TARGET[$__type]}" "${INITIATOR[$__treeAfterFile]}" "${INITIATOR[$__treeCurrentFile]}" "${INITIATOR[$__deletedListFile]}" "${INITIATOR[$__failedDeletedListFile]}" &
targetPid="$!" targetPid="$!"
fi fi
@ -1311,26 +1311,26 @@ function Sync {
for pid in "${pidArray[@]}"; do for pid in "${pidArray[@]}"; do
pid=${pid%:*} pid=${pid%:*}
if [ $pid == $initiatorPid ]; then if [ $pid == $initiatorPid ]; then
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
initiatorFail=true initiatorFail=true
elif [ $pid == $targetPid ]; then elif [ $pid == $targetPid ]; then
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
targetFail=true targetFail=true
fi fi
done done
if [ $initiatorFail == false ]; then if [ $initiatorFail == false ]; then
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
fi fi
if [ $targetFail == false ]; then if [ $targetFail == false ]; then
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
fi fi
exit 1 exit 1
else else
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[2]}" resumeInitiator="${SYNC_ACTION[2]}"
resumeTarget="${SYNC_ACTION[2]}" resumeTarget="${SYNC_ACTION[2]}"
fi fi
@ -1339,22 +1339,22 @@ function Sync {
## Step 2 ## Step 2
if [ "$resumeInitiator" == "${SYNC_ACTION[2]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[2]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[2]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[2]}" ]; then
if [ "$RSYNC_ATTR_ARGS" != "" ]; then if [ "$RSYNC_ATTR_ARGS" != "" ]; then
sync_attrs "${INITIATOR[replicaDir]}" "$TARGET_SYNC_DIR" sync_attrs "${INITIATOR[$__replicaDir]}" "$TARGET_SYNC_DIR"
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME ${FUNCNAME[0]} false $KEEP_LOGGING WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME ${FUNCNAME[0]} false $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
exit 1 exit 1
else else
echo "${SYNC_ACTION[3]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[3]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[3]}" resumeInitiator="${SYNC_ACTION[3]}"
resumeTarget="${SYNC_ACTION[3]}" resumeTarget="${SYNC_ACTION[3]}"
fi fi
else else
echo "${SYNC_ACTION[3]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[3]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[3]}" resumeInitiator="${SYNC_ACTION[3]}"
resumeTarget="${SYNC_ACTION[3]}" resumeTarget="${SYNC_ACTION[3]}"
fi fi
@ -1362,33 +1362,33 @@ function Sync {
## Step 3a & 3b ## Step 3a & 3b
if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then
if [ "$CONFLICT_PREVALANCE" == "${TARGET[type]}" ]; then if [ "$CONFLICT_PREVALANCE" == "${TARGET[$__type]}" ]; then
if [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then if [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then
sync_update "${TARGET[type]}" "${INITIATOR[type]}" "${INITIATOR[deletedListFile]}" sync_update "${TARGET[$__type]}" "${INITIATOR[$__type]}" "${INITIATOR[$__deletedListFile]}"
if [ $? == 0 ]; then if [ $? == 0 ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeTarget="${SYNC_ACTION[4]}" resumeTarget="${SYNC_ACTION[4]}"
fi fi
fi fi
if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ]; then
sync_update "${INITIATOR[type]}" "${TARGET[type]}" "${INITIATOR[deletedListFile]}" sync_update "${INITIATOR[$__type]}" "${TARGET[$__type]}" "${INITIATOR[$__deletedListFile]}"
if [ $? == 0 ]; then if [ $? == 0 ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
resumeInitiator="${SYNC_ACTION[4]}" resumeInitiator="${SYNC_ACTION[4]}"
fi fi
fi fi
else else
if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ]; then
sync_update "${INITIATOR[type]}" "${TARGET[type]}" "${INITIATOR[deletedListFile]}" sync_update "${INITIATOR[$__type]}" "${TARGET[$__type]}" "${INITIATOR[$__deletedListFile]}"
if [ $? == 0 ]; then if [ $? == 0 ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
resumeInitiator="${SYNC_ACTION[4]}" resumeInitiator="${SYNC_ACTION[4]}"
fi fi
fi fi
if [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then if [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then
sync_update "${TARGET[type]}" "${INITIATOR[type]}" "${INITIATOR[deletedListFile]}" sync_update "${TARGET[$__type]}" "${INITIATOR[$__type]}" "${INITIATOR[$__deletedListFile]}"
if [ $? == 0 ]; then if [ $? == 0 ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeTarget="${SYNC_ACTION[4]}" resumeTarget="${SYNC_ACTION[4]}"
fi fi
fi fi
@ -1398,12 +1398,12 @@ function Sync {
## Step 4a & 4b ## Step 4a & 4b
if [ "$resumeInitiator" == "${SYNC_ACTION[4]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[4]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[4]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[4]}" ]; then
if [ "$resumeInitiator" == "${SYNC_ACTION[4]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[4]}" ]; then
deletion_propagation "${TARGET[type]}" "${INITIATOR[deletedListFile]}" "${INITIATOR[failedDeletedListFile]}" & deletion_propagation "${TARGET[$__type]}" "${INITIATOR[$__deletedListFile]}" "${INITIATOR[$__failedDeletedListFile]}" &
initiatorPid="$!" initiatorPid="$!"
fi fi
if [ "$resumeTarget" == "${SYNC_ACTION[4]}" ]; then if [ "$resumeTarget" == "${SYNC_ACTION[4]}" ]; then
deletion_propagation "${INITIATOR[type]}" "${INITIATOR[deletedListFile]}" "${INITIATOR[failedDeletedListFile]}" & deletion_propagation "${INITIATOR[$__type]}" "${INITIATOR[$__deletedListFile]}" "${INITIATOR[$__failedDeletedListFile]}" &
targetPid="$!" targetPid="$!"
fi fi
@ -1415,26 +1415,26 @@ function Sync {
for pid in "${pidArray[@]}"; do for pid in "${pidArray[@]}"; do
pid=${pid%:*} pid=${pid%:*}
if [ $pid == $initiatorPid ]; then if [ $pid == $initiatorPid ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
initiatorFail=true initiatorFail=true
elif [ $pid == $targetPid ]; then elif [ $pid == $targetPid ]; then
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
targetFail=true targetFail=true
fi fi
done done
if [ $initiatorFail == false ]; then if [ $initiatorFail == false ]; then
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
fi fi
if [ $targetFail == false ]; then if [ $targetFail == false ]; then
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
fi fi
exit 1 exit 1
else else
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[5]}" resumeInitiator="${SYNC_ACTION[5]}"
resumeTarget="${SYNC_ACTION[5]}" resumeTarget="${SYNC_ACTION[5]}"
@ -1444,12 +1444,12 @@ function Sync {
## Step 5a & 5b ## Step 5a & 5b
if [ "$resumeInitiator" == "${SYNC_ACTION[5]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[5]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[5]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[5]}" ]; then
if [ "$resumeInitiator" == "${SYNC_ACTION[5]}" ]; then if [ "$resumeInitiator" == "${SYNC_ACTION[5]}" ]; then
tree_list "${INITIATOR[replicaDir]}" "${INITIATOR[type]}" "${INITIATOR[treeAfterFile]}" & tree_list "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" "${INITIATOR[$__treeAfterFile]}" &
initiatorPid="$!" initiatorPid="$!"
fi fi
if [ "$resumeTarget" == "${SYNC_ACTION[5]}" ]; then if [ "$resumeTarget" == "${SYNC_ACTION[5]}" ]; then
tree_list "${TARGET[replicaDir]}" "${TARGET[type]}" "${INITIATOR[treeAfterFile]}" & tree_list "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "${INITIATOR[$__treeAfterFile]}" &
targetPid="$!" targetPid="$!"
fi fi
@ -1461,33 +1461,33 @@ function Sync {
for pid in "${pidArray[@]}"; do for pid in "${pidArray[@]}"; do
pid=${pid%:*} pid=${pid%:*}
if [ $pid == $initiatorPid ]; then if [ $pid == $initiatorPid ]; then
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
initiatorFail=true initiatorFail=true
elif [ $pid == $targetPid ]; then elif [ $pid == $targetPid ]; then
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
targetFail=true targetFail=true
fi fi
done done
if [ $initiatorFail == false ]; then if [ $initiatorFail == false ]; then
echo "${SYNC_ACTION[6]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__initiatorLastActionFile]}"
fi fi
if [ $targetFail == false ]; then if [ $targetFail == false ]; then
echo "${SYNC_ACTION[6]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__targetLastActionFile]}"
fi fi
exit 1 exit 1
else else
echo "${SYNC_ACTION[6]}" > "${INITIATOR[initiatorLastActionFile]}" echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__initiatorLastActionFile]}"
echo "${SYNC_ACTION[6]}" > "${INITIATOR[targetLastActionFile]}" echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__targetLastActionFile]}"
resumeInitiator="${SYNC_ACTION[6]}" resumeInitiator="${SYNC_ACTION[6]}"
resumeTarget="${SYNC_ACTION[6]}" resumeTarget="${SYNC_ACTION[6]}"
fi fi
fi fi
Logger "Finished synchronization task." "NOTICE" Logger "Finished synchronization task." "NOTICE"
echo "0" > "${INITIATOR[resumeCount]}" echo "0" > "${INITIATOR[$__resumeCount]}"
} }
function _SoftDeleteLocal { function _SoftDeleteLocal {
@ -1582,13 +1582,13 @@ function SoftDelete {
if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then
Logger "Running conflict backup cleanup." "NOTICE" Logger "Running conflict backup cleanup." "NOTICE"
_SoftDeleteLocal "${INITIATOR[type]}" "${INITIATOR[replicaDir]}${INITIATOR[backupDir]}" $CONFLICT_BACKUP_DAYS & _SoftDeleteLocal "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__backupDir]}" $CONFLICT_BACKUP_DAYS &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_SoftDeleteLocal "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[backupDir]}" $CONFLICT_BACKUP_DAYS & _SoftDeleteLocal "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__backupDir]}" $CONFLICT_BACKUP_DAYS &
pids="$pids;$!" pids="$pids;$!"
else else
_SoftDeleteRemote "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[backupDir]}" $CONFLICT_BACKUP_DAYS & _SoftDeleteRemote "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__backupDir]}" $CONFLICT_BACKUP_DAYS &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -1597,13 +1597,13 @@ function SoftDelete {
if [ "$SOFT_DELETE" != "no" ] && [ $SOFT_DELETE_DAYS -ne 0 ]; then if [ "$SOFT_DELETE" != "no" ] && [ $SOFT_DELETE_DAYS -ne 0 ]; then
Logger "Running soft deletion cleanup." "NOTICE" Logger "Running soft deletion cleanup." "NOTICE"
_SoftDeleteLocal "${INITIATOR[type]}" "${INITIATOR[replicaDir]}${INITIATOR[deleteDir]}" $SOFT_DELETE_DAYS & _SoftDeleteLocal "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__deleteDir]}" $SOFT_DELETE_DAYS &
pids="$!" pids="$!"
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_SoftDeleteLocal "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[deleteDir]}" $SOFT_DELETE_DAYS & _SoftDeleteLocal "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__deleteDir]}" $SOFT_DELETE_DAYS &
pids="$pids;$!" pids="$pids;$!"
else else
_SoftDeleteRemote "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[deleteDir]}" $SOFT_DELETE_DAYS & _SoftDeleteRemote "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__deleteDir]}" $SOFT_DELETE_DAYS &
pids="$pids;$!" pids="$pids;$!"
fi fi
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
@ -1687,32 +1687,49 @@ function Init {
local dry_suffix= local dry_suffix=
fi fi
declare -gA INITIATOR # The following associative like array definitions are used for bash ver < 4 compat
INITIATOR[type]='initiator' readonly __type=0
INITIATOR[replicaDir]="$INITIATOR_SYNC_DIR" readonly __replicaDir=1
INITIATOR[lockFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$lock_filename" readonly __lockFile=2
INITIATOR[stateDir]="$OSYNC_DIR/$state_dir" readonly __stateDir=3
INITIATOR[backupDir]="$OSYNC_DIR/$backup_dir" readonly __backupDir=4
INITIATOR[deleteDir]="$OSYNC_DIR/$delete_dir" readonly __deleteDir=5
INITIATOR[partialDir]="$OSYNC_DIR/$partial_dir" readonly __partialDir=6
INITIATOR[initiatorLastActionFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/initiator-$last_action-$INSTANCE_ID$dry_suffix" readonly __initiatorLastActionFile=7
INITIATOR[targetLastActionFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/target-$last_action-$INSTANCE_ID$dry_suffix" readonly __targetLastActionFile=8
INITIATOR[resumeCount]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/$resume_count-$INSTANCE_ID$dry_suffix" readonly __resumeCount=9
INITIATOR[treeCurrentFile]="-tree-current-$INSTANCE_ID$dry_suffix" readonly __treeCurrentFile=10
INITIATOR[treeAfterFile]="-tree-after-$INSTANCE_ID$dry_suffix" readonly __treeAfterFile=11
INITIATOR[treeAfterFileNoSuffix]="-tree-after-$INSTANCE_ID" readonly __treeAfterFileNoSuffix=12
INITIATOR[deletedListFile]="-deleted-list-$INSTANCE_ID$dry_suffix" readonly __deletedListfile=13
INITIATOR[failedDeletedListFile]="-failed-delete-$INSTANCE_ID$dry_suffix" readonly __failedDeletedListFile=14
declare -gA TARGET INITIATOR=()
TARGET[type]='target' INITIATOR[$__type]='initiator'
TARGET[replicaDir]="$TARGET_SYNC_DIR" INITIATOR[$__replicaDir]="$INITIATOR_SYNC_DIR"
TARGET[lockFile]="$TARGET_SYNC_DIR$OSYNC_DIR/$lock_filename" INITIATOR[$__lockFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$lock_filename"
TARGET[stateDir]="$OSYNC_DIR/$state_dir" INITIATOR[$__stateDir]="$OSYNC_DIR/$state_dir"
TARGET[backupDir]="$OSYNC_DIR/$backup_dir" INITIATOR[$__backupDir]="$OSYNC_DIR/$backup_dir"
TARGET[deleteDir]="$OSYNC_DIR/$delete_dir" INITIATOR[$__deleteDir]="$OSYNC_DIR/$delete_dir"
INITIATOR[$__partialDir]="$OSYNC_DIR/$partial_dir"
INITIATOR[$__initiatorLastActionFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/initiator-$last_action-$INSTANCE_ID$dry_suffix"
INITIATOR[$__targetLastActionFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/target-$last_action-$INSTANCE_ID$dry_suffix"
INITIATOR[$__resumeCount]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$state_dir/$resume_count-$INSTANCE_ID$dry_suffix"
INITIATOR[$__treeCurrentFile]="-tree-current-$INSTANCE_ID$dry_suffix"
INITIATOR[$__treeAfterFile]="-tree-after-$INSTANCE_ID$dry_suffix"
INITIATOR[$__treeAfterFileNoSuffix]="-tree-after-$INSTANCE_ID"
INITIATOR[$__deletedListFile]="-deleted-list-$INSTANCE_ID$dry_suffix"
INITIATOR[$__failedDeletedListFile]="-failed-delete-$INSTANCE_ID$dry_suffix"
PARTIAL_DIR="${INITIATOR[partialDir]}" TARGET=()
TARGET[$__type]='target'
TARGET[$__replicaDir]="$TARGET_SYNC_DIR"
TARGET[$__lockFile]="$TARGET_SYNC_DIR$OSYNC_DIR/$lock_filename"
TARGET[$__stateDir]="$OSYNC_DIR/$state_dir"
TARGET[$__backupDir]="$OSYNC_DIR/$backup_dir"
TARGET[$__deleteDir]="$OSYNC_DIR/$delete_dir"
PARTIAL_DIR="${INITIATOR[$__partialDir]}"
## Set sync only function arguments for rsync ## Set sync only function arguments for rsync
SYNC_OPTS="-u" SYNC_OPTS="-u"
@ -1732,8 +1749,8 @@ function Init {
## Conflict options ## Conflict options
if [ "$CONFLICT_BACKUP" != "no" ]; then if [ "$CONFLICT_BACKUP" != "no" ]; then
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[replicaDir]}${INITIATOR[backupDir]}\"" INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__backupDir]}\""
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[replicaDir]}${TARGET[backupDir]}\"" TARGET_BACKUP="--backup --backup-dir=\"${TARGET[$__replicaDir]}${TARGET[$__backupDir]}\""
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)"