mirror of
https://github.com/deajan/osync
synced 2024-11-03 15:40:14 +00:00
Rendered associative like arrays bash 3 compatible
This commit is contained in:
parent
f5698c6037
commit
90d16862d2
369
dev/n_osync.sh
369
dev/n_osync.sh
@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||
PROGRAM_VERSION=1.2-beta
|
||||
PROGRAM_BUILD=2016083001
|
||||
PROGRAM_BUILD=2016083002
|
||||
IS_STABLE=no
|
||||
|
||||
# Execution order #__WITH_PARANOIA_DEBUG
|
||||
@ -228,23 +228,23 @@ function CheckReplicaPaths {
|
||||
local pids
|
||||
|
||||
# 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
|
||||
#TARGET_SYNC_DIR_CANN=$(realpath "${TARGET[replicaDir]})
|
||||
#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]})
|
||||
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
if [ "${INITIATOR[replicaDir]}" == "${TARGET[replicaDir]}" ]; then
|
||||
Logger "Initiator and target path [${INITIATOR[replicaDir]}] cannot be the same." "CRITICAL"
|
||||
if [ "${INITIATOR[$__replicaDir]}" == "${TARGET[$__replicaDir]}" ]; then
|
||||
Logger "Initiator and target path [${INITIATOR[$__replicaDir]}] cannot be the same." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
_CheckReplicaPathsLocal "${INITIATOR[replicaDir]}" &
|
||||
_CheckReplicaPathsLocal "${INITIATOR[$__replicaDir]}" &
|
||||
pids="$!"
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_CheckReplicaPathsLocal "${TARGET[replicaDir]}" &
|
||||
_CheckReplicaPathsLocal "${TARGET[$__replicaDir]}" &
|
||||
pids="$pids;$!"
|
||||
else
|
||||
_CheckReplicaPathsRemote "${TARGET[replicaDir]}" &
|
||||
_CheckReplicaPathsRemote "${TARGET[$__replicaDir]}" &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} false $KEEP_LOGGING
|
||||
@ -304,13 +304,13 @@ function CheckDiskSpace {
|
||||
return 0
|
||||
fi
|
||||
|
||||
_CheckDiskSpaceLocal "${INITIATOR[replicaDir]}" &
|
||||
_CheckDiskSpaceLocal "${INITIATOR[$__replicaDir]}" &
|
||||
pids="$!"
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_CheckDiskSpaceLocal "${TARGET[replicaDir]}" &
|
||||
_CheckDiskSpaceLocal "${TARGET[$__replicaDir]}" &
|
||||
pids="$pids;$!"
|
||||
else
|
||||
_CheckDiskSpaceRemote "${TARGET[replicaDir]}" &
|
||||
_CheckDiskSpaceRemote "${TARGET[$__replicaDir]}" &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||
@ -355,13 +355,13 @@ function CreateStateDirs {
|
||||
|
||||
local pids
|
||||
|
||||
_CreateStateDirsLocal "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}" &
|
||||
_CreateStateDirsLocal "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}" &
|
||||
pids="$!"
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_CreateStateDirsLocal "${TARGET[replicaDir]}${TARGET[stateDir]}" &
|
||||
_CreateStateDirsLocal "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}" &
|
||||
pids="$pids;$!"
|
||||
else
|
||||
_CreateStateDirsRemote "${TARGET[replicaDir]}${TARGET[stateDir]}" &
|
||||
_CreateStateDirsRemote "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}" &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||
@ -460,13 +460,13 @@ function CheckLocks {
|
||||
fi
|
||||
fi
|
||||
|
||||
_CheckLocksLocal "${INITIATOR[lockFile]}" &
|
||||
_CheckLocksLocal "${INITIATOR[$__lockFile]}" &
|
||||
pids="$!"
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_CheckLocksLocal "${TARGET[lockFile]}" &
|
||||
_CheckLocksLocal "${TARGET[$__lockFile]}" &
|
||||
pids="$pids;$!"
|
||||
else
|
||||
_CheckLocksRemote "${TARGET[lockFile]}" &
|
||||
_CheckLocksRemote "${TARGET[$__lockFile]}" &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||
@ -520,14 +520,14 @@ function WriteLockFiles {
|
||||
local pidArray
|
||||
local pid
|
||||
|
||||
_WriteLockFilesLocal "${INITIATOR[lockFile]}" "${INITIATOR[type]}"&
|
||||
_WriteLockFilesLocal "${INITIATOR[$__lockFile]}" "${INITIATOR[$__type]}"&
|
||||
initiatorPid="$!"
|
||||
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_WriteLockFilesLocal "${TARGET[lockFile]}" "${TARGET[type]}" &
|
||||
_WriteLockFilesLocal "${TARGET[$__lockFile]}" "${TARGET[$__type]}" &
|
||||
targetPid="$!"
|
||||
else
|
||||
_WriteLockFilesRemote "${TARGET[lockFile]}" "${TARGET[type]}" &
|
||||
_WriteLockFilesRemote "${TARGET[$__lockFile]}" "${TARGET[$__type]}" &
|
||||
targetPid="$!"
|
||||
fi
|
||||
|
||||
@ -594,16 +594,16 @@ function UnlockReplicas {
|
||||
fi
|
||||
|
||||
if [ $INITIATOR_LOCK_FILE_EXISTS == true ]; then
|
||||
_UnlockReplicasLocal "${INITIATOR[lockFile]}" &
|
||||
_UnlockReplicasLocal "${INITIATOR[$__lockFile]}" &
|
||||
pids="$!"
|
||||
fi
|
||||
|
||||
if [ $TARGET_LOCK_FILE_EXISTS == true ]; then
|
||||
if [ "$REMOTE_OPERATION" != "yes" ]; then
|
||||
_UnlockReplicasLocal "${TARGET[lockFile]}" &
|
||||
_UnlockReplicasLocal "${TARGET[$__lockFile]}" &
|
||||
pids="$pids;$!"
|
||||
else
|
||||
_UnlockReplicasRemote "${TARGET[lockFile]}" &
|
||||
_UnlockReplicasRemote "${TARGET[$__lockFile]}" &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
fi
|
||||
@ -633,7 +633,7 @@ function tree_list {
|
||||
escaped_replica_path=$(EscapeSpaces "$replica_path")
|
||||
|
||||
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
|
||||
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\""
|
||||
@ -647,7 +647,7 @@ function tree_list {
|
||||
retval=$?
|
||||
## Retval 24 = some files vanished while creating list
|
||||
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 $?
|
||||
else
|
||||
Logger "Cannot create replica file list in [$replica_path]." "CRITICAL"
|
||||
@ -667,13 +667,13 @@ function delete_list {
|
||||
local cmd
|
||||
|
||||
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
|
||||
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
|
||||
## 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
|
||||
|
||||
Logger "CMD: $cmd" "DEBUG"
|
||||
@ -681,14 +681,14 @@ function delete_list {
|
||||
retval=$?
|
||||
|
||||
# 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
|
||||
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"
|
||||
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"
|
||||
rm -f "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_failed_list_file"
|
||||
fi
|
||||
|
||||
return $retval
|
||||
else
|
||||
touch "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$replica_type$deleted_list_file"
|
||||
touch "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$replica_type$deleted_list_file"
|
||||
return $retval
|
||||
fi
|
||||
}
|
||||
@ -736,7 +736,7 @@ function _get_file_ctime_mtime_remote {
|
||||
function sync_attrs {
|
||||
local initiator_replica="${1}"
|
||||
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
|
||||
|
||||
local rsync_cmd
|
||||
@ -777,15 +777,15 @@ function sync_attrs {
|
||||
fi
|
||||
|
||||
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="$!"
|
||||
|
||||
Logger "Getting ctimes for pending files on target." "NOTICE"
|
||||
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;$!"
|
||||
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;$!"
|
||||
fi
|
||||
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
|
||||
# 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;^${TARGET[replicaDir]};;g" "$RUN_DIR/$PROGRAM.ctime_mtime.${TARGET[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"
|
||||
|
||||
if [ "$CONFLICT_PREVALANCE" == "${TARGET[type]}" ]; then
|
||||
local source_dir="${INITIATOR[replicaDir]}"
|
||||
esc_source_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}")
|
||||
local dest_dir="${TARGET[replicaDir]}"
|
||||
esc_dest_dir=$(EscapeSpaces "${TARGET[replicaDir]}")
|
||||
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"
|
||||
if [ "$CONFLICT_PREVALANCE" == "${TARGET[$__type]}" ]; then
|
||||
local source_dir="${INITIATOR[$__replicaDir]}"
|
||||
esc_source_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
|
||||
local dest_dir="${TARGET[$__replicaDir]}"
|
||||
esc_dest_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
|
||||
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"
|
||||
else
|
||||
local source_dir="${TARGET[replicaDir]}"
|
||||
esc_source_dir=$(EscapeSpaces "${TARGET[replicaDir]}")
|
||||
local dest_dir="${INITIATOR[replicaDir]}"
|
||||
esc_dest_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}")
|
||||
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"
|
||||
local source_dir="${TARGET[$__replicaDir]}"
|
||||
esc_source_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
|
||||
local dest_dir="${INITIATOR[$__replicaDir]}"
|
||||
esc_dest_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
|
||||
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"
|
||||
fi
|
||||
|
||||
if [ $(wc -l < "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-ctime_files.$SCRIPT_PID") -eq 0 ]; then
|
||||
@ -824,13 +824,13 @@ function sync_attrs {
|
||||
CheckConnectivityRemoteHost
|
||||
|
||||
# No rsync args (hence no -r) because files are selected with --from-file
|
||||
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 &"
|
||||
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 &"
|
||||
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
|
||||
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
|
||||
|
||||
@ -867,32 +867,32 @@ function sync_update {
|
||||
local esc_dest_dir
|
||||
|
||||
Logger "Updating $destination_replica replica." "NOTICE"
|
||||
if [ "$source_replica" == "${INITIATOR[type]}" ]; then
|
||||
local source_dir="${INITIATOR[replicaDir]}"
|
||||
local dest_dir="${TARGET[replicaDir]}"
|
||||
if [ "$source_replica" == "${INITIATOR[$__type]}" ]; then
|
||||
local source_dir="${INITIATOR[$__replicaDir]}"
|
||||
local dest_dir="${TARGET[$__replicaDir]}"
|
||||
local backup_args="$TARGET_BACKUP"
|
||||
|
||||
esc_source_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}")
|
||||
esc_dest_dir=$(EscapeSpaces "${TARGET[replicaDir]}")
|
||||
esc_source_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
|
||||
esc_dest_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
|
||||
else
|
||||
local source_dir="${TARGET[replicaDir]}"
|
||||
local dest_dir="${INITIATOR[replicaDir]}"
|
||||
local source_dir="${TARGET[$__replicaDir]}"
|
||||
local dest_dir="${INITIATOR[$__replicaDir]}"
|
||||
local backup_args="$INITIATOR_BACKUP"
|
||||
|
||||
esc_source_dir=$(EscapeSpaces "${TARGET[replicaDir]}")
|
||||
esc_dest_dir=$(EscapeSpaces "${INITIATOR[replicaDir]}")
|
||||
esc_source_dir=$(EscapeSpaces "${TARGET[$__replicaDir]}")
|
||||
esc_dest_dir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
|
||||
fi
|
||||
|
||||
if [ "$REMOTE_OPERATION" == "yes" ]; then
|
||||
CheckConnectivity3rdPartyHosts
|
||||
CheckConnectivityRemoteHost
|
||||
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"
|
||||
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"
|
||||
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
|
||||
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
|
||||
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
|
||||
eval "$rsync_cmd"
|
||||
@ -956,7 +956,7 @@ function _delete_local {
|
||||
fi
|
||||
if [ $? != 0 ]; then
|
||||
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
|
||||
@ -968,14 +968,14 @@ function _delete_local {
|
||||
Logger "Deleting [$replica_dir$files]." "VERBOSE"
|
||||
if [ $result != 0 ]; then
|
||||
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
|
||||
previous_file="$files"
|
||||
fi
|
||||
done < "${INITIATOR[replicaDir]}${INITIATOR[stateDir]}/$deleted_list_file"
|
||||
done < "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deleted_list_file"
|
||||
}
|
||||
|
||||
function _delete_remote {
|
||||
@ -992,8 +992,8 @@ function _delete_remote {
|
||||
## Anything beetween << ENDSSH and ENDSSH will be executed remotely
|
||||
|
||||
# Additionnaly, we need to copy the deletetion list to the remote state folder
|
||||
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"
|
||||
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"
|
||||
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
|
||||
eval "$rsync_cmd" 2>> "$LOG_FILE"
|
||||
if [ $? != 0 ]; then
|
||||
@ -1004,7 +1004,7 @@ function _delete_remote {
|
||||
exit 1
|
||||
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
|
||||
function _logger {
|
||||
@ -1111,8 +1111,8 @@ ENDSSH
|
||||
fi
|
||||
|
||||
## Copy back the deleted failed file list
|
||||
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\""
|
||||
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\""
|
||||
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
|
||||
eval "$rsync_cmd" 2>> "$LOG_FILE"
|
||||
result=$?
|
||||
@ -1138,24 +1138,24 @@ function deletion_propagation {
|
||||
|
||||
Logger "Propagating deletions to $replica_type replica." "NOTICE"
|
||||
|
||||
if [ "$replica_type" == "${INITIATOR[type]}" ]; then
|
||||
replica_dir="${INITIATOR[replicaDir]}"
|
||||
delete_dir="${INITIATOR[deleteDir]}"
|
||||
if [ "$replica_type" == "${INITIATOR[$__type]}" ]; then
|
||||
replica_dir="${INITIATOR[$__replicaDir]}"
|
||||
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=$?
|
||||
if [ $retval != 0 ]; then
|
||||
Logger "Deletion on replica $replica_type failed." "CRITICAL"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
replica_dir="${TARGET[replicaDir]}"
|
||||
delete_dir="${TARGET[deleteDir]}"
|
||||
replica_dir="${TARGET[$__replicaDir]}"
|
||||
delete_dir="${TARGET[$__deleteDir]}"
|
||||
|
||||
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
|
||||
_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
|
||||
retval=$?
|
||||
if [ $retval == 0 ]; then
|
||||
@ -1200,41 +1200,41 @@ function Sync {
|
||||
CheckConnectivityRemoteHost
|
||||
|
||||
if [ "$RESUME_SYNC" != "no" ]; then
|
||||
if [ -f "${INITIATOR[resumeCount]}" ]; then
|
||||
resumeCount=$(cat "${INITIATOR[resumeCount]}")
|
||||
if [ -f "${INITIATOR[$__resumeCount]}" ]; then
|
||||
resumeCount=$(cat "${INITIATOR[$__resumeCount]}")
|
||||
else
|
||||
resumeCount=0
|
||||
fi
|
||||
|
||||
if [ $resumeCount -lt $RESUME_TRY ]; then
|
||||
if [ -f "${INITIATOR[initiatorLastActionFile]}" ]; then
|
||||
resumeInitiator=$(cat "${INITIATOR[initiatorLastActionFile]}")
|
||||
if [ -f "${INITIATOR[$__initiatorLastActionFile]}" ]; then
|
||||
resumeInitiator=$(cat "${INITIATOR[$__initiatorLastActionFile]}")
|
||||
else
|
||||
resumeInitiator="synced"
|
||||
fi
|
||||
|
||||
if [ -f "${INITIATOR[targetLastActionFile]}" ]; then
|
||||
resumeTarget=$(cat "${INITIATOR[targetLastActionFile]}")
|
||||
if [ -f "${INITIATOR[$__targetLastActionFile]}" ]; then
|
||||
resumeTarget=$(cat "${INITIATOR[$__targetLastActionFile]}")
|
||||
else
|
||||
resumeTarget="synced"
|
||||
fi
|
||||
|
||||
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"
|
||||
echo $(($resumeCount+1)) > "${INITIATOR[resumeCount]}"
|
||||
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]}"
|
||||
else
|
||||
resumeInitiator="none"
|
||||
fi
|
||||
|
||||
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"
|
||||
echo $(($resumeCount+1)) > "${INITIATOR[resumeCount]}"
|
||||
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]}"
|
||||
else
|
||||
resumeTarget="none"
|
||||
fi
|
||||
else
|
||||
Logger "Will not resume aborted execution. Too many resume tries [$resumeCount]." "WARN"
|
||||
echo "0" > "${INITIATOR[resumeCount]}"
|
||||
echo "0" > "${INITIATOR[$__resumeCount]}"
|
||||
resumeInitiator="none"
|
||||
resumeTarget="none"
|
||||
fi
|
||||
@ -1249,12 +1249,12 @@ function Sync {
|
||||
## Step 0a & 0b
|
||||
if [ "$resumeInitiator" == "none" ] || [ "$resumeTarget" == "none" ] || [ "$resumeInitiator" == "${SYNC_ACTION[0]}" ] || [ "$resumeTarget" == "${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="$!"
|
||||
fi
|
||||
|
||||
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="$!"
|
||||
fi
|
||||
|
||||
@ -1266,26 +1266,26 @@ function Sync {
|
||||
for pid in "${pidArray[@]}"; do
|
||||
pid=${pid%:*}
|
||||
if [ $pid == $initiatorPid ]; then
|
||||
echo "${SYNC_ACTION[0]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[0]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
initiatorFail=true
|
||||
elif [ $pid == $targetPid ]; then
|
||||
echo "${SYNC_ACTION[0]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[0]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
targetFail=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $initiatorFail == false ]; then
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
fi
|
||||
|
||||
if [ $targetFail == false ]; then
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
else
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[1]}"
|
||||
resumeTarget="${SYNC_ACTION[1]}"
|
||||
fi
|
||||
@ -1294,12 +1294,12 @@ function Sync {
|
||||
## Step 1a & 1b
|
||||
if [ "$resumeInitiator" == "${SYNC_ACTION[1]}" ] || [ "$resumeTarget" == "${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="$!"
|
||||
fi
|
||||
|
||||
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="$!"
|
||||
fi
|
||||
|
||||
@ -1311,26 +1311,26 @@ function Sync {
|
||||
for pid in "${pidArray[@]}"; do
|
||||
pid=${pid%:*}
|
||||
if [ $pid == $initiatorPid ]; then
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
initiatorFail=true
|
||||
elif [ $pid == $targetPid ]; then
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[1]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
targetFail=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $initiatorFail == false ]; then
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
fi
|
||||
|
||||
if [ $targetFail == false ]; then
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
else
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[2]}"
|
||||
resumeTarget="${SYNC_ACTION[2]}"
|
||||
fi
|
||||
@ -1339,22 +1339,22 @@ function Sync {
|
||||
## Step 2
|
||||
if [ "$resumeInitiator" == "${SYNC_ACTION[2]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[2]}" ]; 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
|
||||
if [ $? != 0 ]; then
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[2]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
exit 1
|
||||
else
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[3]}"
|
||||
resumeTarget="${SYNC_ACTION[3]}"
|
||||
|
||||
fi
|
||||
else
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[3]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[3]}"
|
||||
resumeTarget="${SYNC_ACTION[3]}"
|
||||
fi
|
||||
@ -1362,33 +1362,33 @@ function Sync {
|
||||
|
||||
## Step 3a & 3b
|
||||
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
|
||||
sync_update "${TARGET[type]}" "${INITIATOR[type]}" "${INITIATOR[deletedListFile]}"
|
||||
sync_update "${TARGET[$__type]}" "${INITIATOR[$__type]}" "${INITIATOR[$__deletedListFile]}"
|
||||
if [ $? == 0 ]; then
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeTarget="${SYNC_ACTION[4]}"
|
||||
fi
|
||||
fi
|
||||
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
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[4]}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
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
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[4]}"
|
||||
fi
|
||||
fi
|
||||
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
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeTarget="${SYNC_ACTION[4]}"
|
||||
fi
|
||||
fi
|
||||
@ -1398,12 +1398,12 @@ function Sync {
|
||||
## Step 4a & 4b
|
||||
if [ "$resumeInitiator" == "${SYNC_ACTION[4]}" ] || [ "$resumeTarget" == "${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="$!"
|
||||
fi
|
||||
|
||||
if [ "$resumeTarget" == "${SYNC_ACTION[4]}" ]; then
|
||||
deletion_propagation "${INITIATOR[type]}" "${INITIATOR[deletedListFile]}" "${INITIATOR[failedDeletedListFile]}" &
|
||||
deletion_propagation "${INITIATOR[$__type]}" "${INITIATOR[$__deletedListFile]}" "${INITIATOR[$__failedDeletedListFile]}" &
|
||||
targetPid="$!"
|
||||
fi
|
||||
|
||||
@ -1415,26 +1415,26 @@ function Sync {
|
||||
for pid in "${pidArray[@]}"; do
|
||||
pid=${pid%:*}
|
||||
if [ $pid == $initiatorPid ]; then
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
initiatorFail=true
|
||||
elif [ $pid == $targetPid ]; then
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[4]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
targetFail=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $initiatorFail == false ]; then
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
fi
|
||||
|
||||
if [ $targetFail == false ]; then
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
else
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[5]}"
|
||||
resumeTarget="${SYNC_ACTION[5]}"
|
||||
|
||||
@ -1444,12 +1444,12 @@ function Sync {
|
||||
## Step 5a & 5b
|
||||
if [ "$resumeInitiator" == "${SYNC_ACTION[5]}" ] || [ "$resumeTarget" == "${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="$!"
|
||||
fi
|
||||
|
||||
if [ "$resumeTarget" == "${SYNC_ACTION[5]}" ]; then
|
||||
tree_list "${TARGET[replicaDir]}" "${TARGET[type]}" "${INITIATOR[treeAfterFile]}" &
|
||||
tree_list "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "${INITIATOR[$__treeAfterFile]}" &
|
||||
targetPid="$!"
|
||||
fi
|
||||
|
||||
@ -1461,33 +1461,33 @@ function Sync {
|
||||
for pid in "${pidArray[@]}"; do
|
||||
pid=${pid%:*}
|
||||
if [ $pid == $initiatorPid ]; then
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
initiatorFail=true
|
||||
elif [ $pid == $targetPid ]; then
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[5]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
targetFail=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $initiatorFail == false ]; then
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
fi
|
||||
|
||||
if [ $targetFail == false ]; then
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
else
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[targetLastActionFile]}"
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__initiatorLastActionFile]}"
|
||||
echo "${SYNC_ACTION[6]}" > "${INITIATOR[$__targetLastActionFile]}"
|
||||
resumeInitiator="${SYNC_ACTION[6]}"
|
||||
resumeTarget="${SYNC_ACTION[6]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
Logger "Finished synchronization task." "NOTICE"
|
||||
echo "0" > "${INITIATOR[resumeCount]}"
|
||||
echo "0" > "${INITIATOR[$__resumeCount]}"
|
||||
}
|
||||
|
||||
function _SoftDeleteLocal {
|
||||
@ -1582,13 +1582,13 @@ function SoftDelete {
|
||||
if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then
|
||||
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="$!"
|
||||
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;$!"
|
||||
else
|
||||
_SoftDeleteRemote "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[backupDir]}" $CONFLICT_BACKUP_DAYS &
|
||||
_SoftDeleteRemote "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__backupDir]}" $CONFLICT_BACKUP_DAYS &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
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
|
||||
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="$!"
|
||||
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;$!"
|
||||
else
|
||||
_SoftDeleteRemote "${TARGET[type]}" "${TARGET[replicaDir]}${TARGET[deleteDir]}" $SOFT_DELETE_DAYS &
|
||||
_SoftDeleteRemote "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__deleteDir]}" $SOFT_DELETE_DAYS &
|
||||
pids="$pids;$!"
|
||||
fi
|
||||
WaitForTaskCompletion $pids 720 1800 ${FUNCNAME[0]} true $KEEP_LOGGING
|
||||
@ -1687,32 +1687,49 @@ function Init {
|
||||
local dry_suffix=
|
||||
fi
|
||||
|
||||
declare -gA INITIATOR
|
||||
INITIATOR[type]='initiator'
|
||||
INITIATOR[replicaDir]="$INITIATOR_SYNC_DIR"
|
||||
INITIATOR[lockFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$lock_filename"
|
||||
INITIATOR[stateDir]="$OSYNC_DIR/$state_dir"
|
||||
INITIATOR[backupDir]="$OSYNC_DIR/$backup_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"
|
||||
# The following associative like array definitions are used for bash ver < 4 compat
|
||||
readonly __type=0
|
||||
readonly __replicaDir=1
|
||||
readonly __lockFile=2
|
||||
readonly __stateDir=3
|
||||
readonly __backupDir=4
|
||||
readonly __deleteDir=5
|
||||
readonly __partialDir=6
|
||||
readonly __initiatorLastActionFile=7
|
||||
readonly __targetLastActionFile=8
|
||||
readonly __resumeCount=9
|
||||
readonly __treeCurrentFile=10
|
||||
readonly __treeAfterFile=11
|
||||
readonly __treeAfterFileNoSuffix=12
|
||||
readonly __deletedListfile=13
|
||||
readonly __failedDeletedListFile=14
|
||||
|
||||
declare -gA 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"
|
||||
INITIATOR=()
|
||||
INITIATOR[$__type]='initiator'
|
||||
INITIATOR[$__replicaDir]="$INITIATOR_SYNC_DIR"
|
||||
INITIATOR[$__lockFile]="$INITIATOR_SYNC_DIR$OSYNC_DIR/$lock_filename"
|
||||
INITIATOR[$__stateDir]="$OSYNC_DIR/$state_dir"
|
||||
INITIATOR[$__backupDir]="$OSYNC_DIR/$backup_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
|
||||
SYNC_OPTS="-u"
|
||||
@ -1732,8 +1749,8 @@ function Init {
|
||||
|
||||
## Conflict options
|
||||
if [ "$CONFLICT_BACKUP" != "no" ]; then
|
||||
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[replicaDir]}${INITIATOR[backupDir]}\""
|
||||
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[replicaDir]}${TARGET[backupDir]}\""
|
||||
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[$__replicaDir]}${INITIATOR[$__backupDir]}\""
|
||||
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[$__replicaDir]}${TARGET[$__backupDir]}\""
|
||||
if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then
|
||||
INITIATOR_BACKUP="$INITIATOR_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
|
||||
TARGET_BACKUP="$TARGET_BACKUP --suffix .$(date +%Y.%m.%d-%H.%M.%S)"
|
||||
|
Loading…
Reference in New Issue
Block a user