Updated config file structure, checks and upgrade script

pull/163/head
deajan 5 years ago
parent f3bbaceb73
commit f1cf7eb8e2

@ -4,12 +4,14 @@
#Check dryruns with nosuffix mode for timestampList
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2018 by Orsiris de Jong"
AUTHOR="(C) 2013-2019 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.3.0-pre-rc1
PROGRAM_BUILD=2018122901
PROGRAM_BUILD=2019011001
IS_STABLE=no
CONFIG_FILE_REVISION_REQUIRED=1.3.0
##### Execution order #__WITH_PARANOIA_DEBUG
##### Function Name Is parallel #__WITH_PARANOIA_DEBUG
# GetLocalOS no #__WITH_PARANOIA_DEBUG
@ -79,11 +81,11 @@ function TrapQuit {
if [ $ERROR_ALERT == true ]; then
UnlockReplicas
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
RunAfterHook
fi
Logger "$PROGRAM finished with errors." "ERROR"
if [ "$_DEBUG" != "yes" ]
if [ "$_DEBUG" != true ]
then
SendAlert
else
@ -92,11 +94,11 @@ function TrapQuit {
exitcode=1
elif [ $WARN_ALERT == true ]; then
UnlockReplicas
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
RunAfterHook
fi
Logger "$PROGRAM finished with warnings." "WARN"
if [ "$_DEBUG" != "yes" ]
if [ "$_DEBUG" != true ]
then
SendAlert
else
@ -118,7 +120,7 @@ function TrapQuit {
function CheckEnvironment {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
if ! type ssh > /dev/null 2>&1 ; then
Logger "ssh not present. Cannot start sync." "CRITICAL"
exit 1
@ -150,7 +152,7 @@ function CheckEnvironment {
exit 1
fi
if [ "$SUDO_EXEC" == "yes" ]; then
if [ "$SUDO_EXEC" == true ]; then
if ! type sudo > /dev/null 2>&1 ; then
Logger "sudo not present. Sync cannot start." "CRITICAL"
exit 1
@ -162,22 +164,29 @@ function CheckEnvironment {
function CheckCurrentConfig {
local fullCheck="${1:-true}"
local test
local booleans
local num_vars
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
# Full check is for initiator driven runs
if [ $fullCheck == true ]; then
declare -a yes_no_vars=(CREATE_DIRS SUDO_EXEC SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS CHECKSUM RSYNC_COMPRESS CONFLICT_BACKUP CONFLICT_BACKUP_MULTIPLE SOFT_DELETE RESUME_SYNC FORCE_STRANGER_LOCK_RESUME PARTIAL DELTA_COPIES STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
declare -a booleans=(CREATE_DIRS SUDO_EXEC SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS CHECKSUM RSYNC_COMPRESS CONFLICT_BACKUP CONFLICT_BACKUP_MULTIPLE SOFT_DELETE RESUME_SYNC FORCE_STRANGER_LOCK_RESUME PARTIAL DELTA_COPIES STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
declare -a num_vars=(MINIMUM_SPACE BANDWIDTH SOFT_MAX_EXEC_TIME HARD_MAX_EXEC_TIME KEEP_LOGGING MIN_WAIT MAX_WAIT CONFLICT_BACKUP_DAYS SOFT_DELETE_DAYS RESUME_TRY MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER)
# target-helper runs need less configuration
else
declare -a yes_no_vars=(SUDO_EXEC SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
declare -a booleans=(SUDO_EXEC SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
declare -a num_vars=(KEEP_LOGGING MIN_WAIT MAX_WAIT)
fi
# Check all variables that should contain "yes" or "no"
for i in "${yes_no_vars[@]}"; do
test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it using the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
# v2 config will use true / false instead of yes / no
# Check all variables that should contain "yes" or "no", true or false
for i in "${booleans[@]}"; do
#test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ] && [ \"\$$i\" != true ] && [ \"\$$i\" != false ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it using the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
test="if [ \"\$$i\" != true ] && [ \"\$$i\" != false ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it using the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
eval "$test"
# Fix for upcomming v2 where yes and no do not exist anymore
done
# Check all variables that should contain a numerical value >= 0
@ -187,6 +196,19 @@ function CheckCurrentConfig {
done
}
# Change all booleans with "yes" or "no" to true / false for v2 config syntax compatibility
function UpdateBooleans {
local update
local booleans
declare -a booleans=(CREATE_DIRS SUDO_EXEC SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS CHECKSUM RSYNC_COMPRESS CONFLICT_BACKUP CONFLICT_BACKUP_MULTIPLE SOFT_DELETE RESUME_SYNC FORCE_STRANGER_LOCK_RESUME PARTIAL DELTA_COPIES STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
for i in "${booleans[@]}"; do
update="if [ \"\$$i\" == \"yes\" ]; then $i=true; fi; if [ \"\$$i\" == \"no\" ]; then $i=false; fi"
eval "$update"
done
}
# Gets checked in quicksync and config file mode
function CheckCurrentConfigAll {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
@ -208,7 +230,7 @@ function CheckCurrentConfigAll {
exit 1
fi
if [ "$REMOTE_OPERATION" == "yes" ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
if [ "$REMOTE_OPERATION" == true ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL"
exit 1
fi
@ -235,7 +257,7 @@ function _CheckReplicasLocal {
local diskSpace
if [ ! -d "$replicaPath" ]; then
if [ "$CREATE_DIRS" == "yes" ]; then
if [ "$CREATE_DIRS" == true ]; then
mkdir -p "$replicaPath" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" 2>&1
retval=$?
if [ $retval -ne 0 ]; then
@ -300,7 +322,7 @@ include #### CleanUp SUBSET ####
function _CheckReplicasRemoteSub {
if [ ! -d "$replicaPath" ]; then
if [ "$CREATE_DIRS" == "yes" ]; then
if [ "$CREATE_DIRS" == true ]; then
mkdir -p "$replicaPath"
retval=$?
if [ $retval -ne 0 ]; then
@ -366,7 +388,7 @@ function CheckReplicas {
local targetPid
local retval
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
if [ "${INITIATOR[$__replicaDir]}" == "${TARGET[$__replicaDir]}" ]; then
Logger "Initiator and target path [${INITIATOR[$__replicaDir]}] cannot be the same." "CRITICAL"
exit 1
@ -375,7 +397,7 @@ function CheckReplicas {
_CheckReplicasLocal "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" &
initiatorPid=$!
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_CheckReplicasLocal "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" &
targetPid=$!
else
@ -528,7 +550,7 @@ function _HandleLocksRemoteSub {
RemoteLogger "There is a remote dead osync lock [$lockPid@$lockInstanceID] on target replica that corresponds to this initiator INSTANCE_ID. Pid [$lockPid] no longer running. Resuming." "NOTICE"
writeLocks=true
else
if [ "$FORCE_STRANGER_LOCK_RESUME" == "yes" ]; then
if [ "$FORCE_STRANGER_LOCK_RESUME" == true ]; then
RemoteLogger "There is a remote (maybe dead) osync lock [$lockPid@$lockInstanceID] on target replica that does not correspond to this initiator INSTANCE_ID. Forcing resume." "WARN"
writeLocks=true
else
@ -602,7 +624,7 @@ function HandleLocks {
_HandleLocksLocal "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}" "${INITIATOR[$__lockFile]}" "${INITIATOR[$__type]}" $overwrite &
initiatorPid=$!
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_HandleLocksLocal "${TARGET[$__replicaDir]}${TARGET[$__stateDir]}" "${TARGET[$__lockFile]}" "${TARGET[$__type]}" $overwrite &
targetPid=$!
else
@ -706,7 +728,7 @@ function UnlockReplicas {
fi
if [ $TARGET_LOCK_FILE_EXISTS == true ]; then
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_UnlockReplicasLocal "${TARGET[$__lockFile]}" "${TARGET[$__type]}" &
targetPid=$!
else
@ -759,7 +781,7 @@ function treeList {
# (grep -v \"^\.$\" || :) = Removes line containing current directory sign '.'
Logger "Creating $replicaType replica file list [$replicaPath]." "NOTICE"
if [ "$REMOTE_OPERATION" == "yes" ] && [ "$replicaType" == "${TARGET[$__type]}" ]; then
if [ "$REMOTE_OPERATION" == true ] && [ "$replicaType" == "${TARGET[$__type]}" ]; then
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
rsyncCmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"env LC_ALL=C env _REMOTE_TOKEN=$_REMOTE_TOKEN $RSYNC_PATH\" $RSYNC_DEFAULT_ARGS $RSYNC_ATTR_ARGS $RSYNC_TYPE_ARGS --exclude \"$OSYNC_DIR\" $RSYNC_FULL_PATTERNS $RSYNC_PARTIAL_EXCLUDE -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$escapedReplicaPath\" 2> \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP\" | (grep -E \"^-|^d|^l\" || :) | (sed $SED_REGEX_ARG 's/^.{10} +[0-9,]+ [0-9/]{10} [0-9:]{8} //' || :) | (awk 'BEGIN { FS=\" -> \" } ; { print \$1 }' || :) | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP\""
@ -985,7 +1007,7 @@ function timestampList {
Logger "Getting file stats for $replicaType replica [$replicaPath]." "NOTICE"
if [ "$REMOTE_OPERATION" == "yes" ] && [ "$replicaType" == "${TARGET[$__type]}" ]; then
if [ "$REMOTE_OPERATION" == true ] && [ "$replicaType" == "${TARGET[$__type]}" ]; then
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
_getFileCtimeMtimeRemote "$replicaPath" "$replicaType" "$fileList" "$timestampFilename"
@ -1091,7 +1113,7 @@ function syncAttrs {
Logger "Getting list of files that need updates." "NOTICE"
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
rsyncCmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"env LC_ALL=C env _REMOTE_TOKEN=$_REMOTE_TOKEN $RSYNC_PATH\" -i -n $RSYNC_DEFAULT_ARGS $RSYNC_ATTR_ARGS $RSYNC_PARTIAL_EXCLUDE -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_FULL_PATTERNS $RSYNC_PARTIAL_EXCLUDE \"$initiatorReplica\" $REMOTE_USER@$REMOTE_HOST:\"$targetReplica\" >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1"
@ -1127,7 +1149,7 @@ function syncAttrs {
initiatorPid=$!
Logger "Getting ctimes for pending files on target." "NOTICE"
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_getFileCtimeMtimeLocal "${TARGET[$__replicaDir]}" "${TARGET[$__type]}" "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID.$TSTAMP" "$RUN_DIR/$PROGRAM.ctime_mtime___.${TARGET[$__type]}.$SCRIPT_PID.$TSTAMP" &
targetPid=$!
else
@ -1170,7 +1192,7 @@ function syncAttrs {
Logger "Updating file attributes on $destReplica." "NOTICE"
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
@ -1238,7 +1260,7 @@ function syncUpdate {
escDestDir=$(EscapeSpaces "${INITIATOR[$__replicaDir]}")
fi
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
if [ "$sourceReplica" == "${INITIATOR[$__type]}" ]; then
@ -1302,7 +1324,7 @@ function _deleteLocal {
while read -r files; do
## On every run, check wheter the next item is already deleted because it is included in a directory already deleted
if [[ "$files" != "$previousFile/"* ]] && [ "$files" != "" ]; then
if [ "$SOFT_DELETE" != "no" ]; then
if [ "$SOFT_DELETE" != false ]; then
if [ $_DRYRUN == false ]; then
if [ -e "$replicaDir$deletionDir/$files" ] || [ -L "$replicaDir$deletionDir/$files" ]; then
rm -rf "${replicaDir:?}$deletionDir/$files"
@ -1439,7 +1461,7 @@ function _deleteRemoteSub {
## On every run, check wheter the next item is already deleted because it is included in a directory already deleted
if [[ "$files" != "$previousFile/"* ]] && [ "$files" != "" ]; then
if [ "$SOFT_DELETE" != "no" ]; then
if [ "$SOFT_DELETE" != false ]; then
if [ $_DRYRUN == false ]; then
if [ -e "$REPLICA_DIR$DELETION_DIR/$files" ] || [ -L "$REPLICA_DIR$DELETION_DIR/$files" ]; then
rm -rf "$REPLICA_DIR$DELETION_DIR/$files"
@ -1501,7 +1523,7 @@ function _deleteRemoteSub {
exit $retval
ENDSSH
retval=$?
if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ] && ([ $retval -ne 0 ] || [ "$_LOGGER_VERBOSE" == "yes" ]); then
if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ] && ([ $retval -ne 0 ] || [ "$_LOGGER_VERBOSE" == true ]); then
(
_LOGGER_PREFIX="RR"
Logger "$(cat $RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP)" "ERROR"
@ -1553,7 +1575,7 @@ function deletionPropagation {
replicaDir="${TARGET[$__replicaDir]}"
deleteDir="${TARGET[$__deleteDir]}"
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
_deleteRemote "${TARGET[$__type]}" "$replicaDir" "$deleteDir"
else
_deleteLocal "${TARGET[$__type]}" "$replicaDir" "$deleteDir"
@ -1651,7 +1673,7 @@ function Sync {
Logger "Starting synchronization task." "NOTICE"
if [ "$RESUME_SYNC" != "no" ]; then
if [ "$RESUME_SYNC" != false ]; then
if [ -f "${INITIATOR[$__resumeCount]}" ]; then
resumeCount=$(cat "${INITIATOR[$__resumeCount]}")
else
@ -1792,9 +1814,9 @@ function Sync {
## Step 2a & 2b
if [ "$resumeInitiator" == "${SYNC_ACTION[2]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[2]}" ]; then
#if [[ "$RSYNC_ATTR_ARGS" == *"-X"* ]] || [[ "$RSYNC_ATTR_ARGS" == *"-A"* ]] || [ "$LOG_CONFLICTS" == "yes" ]; then
#if [[ "$RSYNC_ATTR_ARGS" == *"-X"* ]] || [[ "$RSYNC_ATTR_ARGS" == *"-A"* ]] || [ "$LOG_CONFLICTS" == true ]; then
#TODO: refactor in v1.3 with syncattrs
if [ "$LOG_CONFLICTS" == "yes" ]; then
if [ "$LOG_CONFLICTS" == true ]; then
if [ "$resumeInitiator" == "${SYNC_ACTION[2]}" ]; then
timestampList "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}${INITIATOR[$__treeCurrentFile]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}${INITIATOR[$__timestampCurrentFile]}" &
@ -1847,7 +1869,7 @@ function Sync {
## Step 3a & 3b
if [ "$resumeInitiator" == "${SYNC_ACTION[3]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[3]}" ]; then
if [ "$LOG_CONFLICTS" == "yes" ]; then
if [ "$LOG_CONFLICTS" == true ]; then
conflictList "${INITIATOR[$__timestampCurrentFile]}" "${INITIATOR[$__timestampAfterFileNoSuffix]}" &
ExecTasks $! "${FUNCNAME[0]}_conflictList" false 0 0 $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME false $SLEEP_TIME $KEEP_LOGGING
if [ $? -ne 0 ]; then
@ -2040,9 +2062,9 @@ function Sync {
# Step 8a & 8b
if [ "$resumeInitiator" == "${SYNC_ACTION[8]}" ] || [ "$resumeTarget" == "${SYNC_ACTION[8]}" ]; then
#if [[ "$RSYNC_ATTR_ARGS" == *"-X"* ]] || [[ "$RSYNC_ATTR_ARGS" == *"-A"* ]] || [ "$LOG_CONFLICTS" == "yes" ]; then
#if [[ "$RSYNC_ATTR_ARGS" == *"-X"* ]] || [[ "$RSYNC_ATTR_ARGS" == *"-A"* ]] || [ "$LOG_CONFLICTS" == true ]; then
#TODO: refactor in v1.3 with syncattrs
if [ "$LOG_CONFLICTS" == "yes" ]; then
if [ "$LOG_CONFLICTS" == true ]; then
if [ "$resumeInitiator" == "${SYNC_ACTION[8]}" ]; then
timestampList "${INITIATOR[$__replicaDir]}" "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}${INITIATOR[$__treeAfterFile]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__type]}${INITIATOR[$__timestampAfterFile]}" &
@ -2249,12 +2271,12 @@ function SoftDelete {
local initiatorPid
local targetPid
if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then
if [ "$CONFLICT_BACKUP" != false ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then
Logger "Running conflict backup cleanup." "NOTICE"
_SoftDeleteLocal "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__backupDir]}" $CONFLICT_BACKUP_DAYS "conflict backup" &
initiatorPid=$!
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_SoftDeleteLocal "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__backupDir]}" $CONFLICT_BACKUP_DAYS "conflict backup" &
targetPid=$!
else
@ -2267,12 +2289,12 @@ function SoftDelete {
fi
fi
if [ "$SOFT_DELETE" != "no" ] && [ $SOFT_DELETE_DAYS -ne 0 ]; then
if [ "$SOFT_DELETE" != false ] && [ $SOFT_DELETE_DAYS -ne 0 ]; then
Logger "Running soft deletion cleanup." "NOTICE"
_SoftDeleteLocal "${INITIATOR[$__type]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__deleteDir]}" $SOFT_DELETE_DAYS "softdelete" &
initiatorPid=$!
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
_SoftDeleteLocal "${TARGET[$__type]}" "${TARGET[$__replicaDir]}${TARGET[$__deleteDir]}" $SOFT_DELETE_DAYS "softdelete" &
targetPid=$!
else
@ -2350,7 +2372,7 @@ ENDSSH
function TriggerInitiatorRun {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" != "no" ]; then
if [ "$REMOTE_OPERATION" != false ]; then
_TriggerInitiatorRunRemote
else
_TriggerInitiatorRunLocal
@ -2405,7 +2427,7 @@ function Summary {
_SummaryFromRsyncFile "${INITIATOR[$__replicaDir]}" "$RUN_DIR/$PROGRAM.update.initiator.$SCRIPT_PID.$TSTAMP" "+ <<"
Logger "File deletions: INITIATOR << >> TARGET" "ALWAYS"
if [ "$REMOTE_OPERATION" == "yes" ]; then
if [ "$REMOTE_OPERATION" == true ]; then
_SummaryFromDeleteFile "${TARGET[$__replicaDir]}" "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/target${TARGET[$__successDeletedListFile]}" "- >>"
else
_SummaryFromDeleteFile "${TARGET[$__replicaDir]}" "$RUN_DIR/$PROGRAM.delete.target.$SCRIPT_PID.$TSTAMP" "- >>"
@ -2435,7 +2457,7 @@ function LogConflicts {
Logger "No conflictList file." "NOTICE"
fi
if [ "$ALERT_CONFLICTS" == "yes" ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then
if [ "$ALERT_CONFLICTS" == true ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then
subject="Conflictual files found in [$INSTANCE_ID]"
body="List of conflictual files:"$'\n'"$(cat ${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]})"
@ -2451,7 +2473,7 @@ function Init {
set -o errtrace
# Do not use exit and quit traps if osync runs in monitor mode
if [ $_SYNC_ON_CHANGES == "no" ]; then
if [ $_SYNC_ON_CHANGES == false ]; then
trap TrapStop INT HUP TERM QUIT
trap TrapQuit EXIT
else
@ -2465,7 +2487,7 @@ function Init {
## Test if target dir is a ssh uri, and if yes, break it down it its values
if [ "${TARGET_SYNC_DIR:0:6}" == "ssh://" ]; then
REMOTE_OPERATION="yes"
REMOTE_OPERATION=true
# remove leadng 'ssh://'
uri=${TARGET_SYNC_DIR#ssh://*}
@ -2497,7 +2519,7 @@ function Init {
# remove everything before first '/'
TARGET_SYNC_DIR=${hosturiandpath#*/}
elif [ "${INITIATOR_SYNC_DIR:0:6}" == "ssh://" ]; then
REMOTE_OPERATION="yes"
REMOTE_OPERATION=true
# remove leadng 'ssh://'
uri=${INITIATOR_SYNC_DIR#ssh://*}
@ -2529,7 +2551,7 @@ function Init {
# remove everything before first '/'
INITIATOR_SYNC_DIR=${hosturiandpath#*/}
else
REMOTE_OPERATION="no"
REMOTE_OPERATION=false
fi
if [ "$INITIATOR_SYNC_DIR" == "" ] || [ "$TARGET_SYNC_DIR" == "" ]; then
@ -2653,10 +2675,10 @@ function Init {
fi
## Conflict options
if [ "$CONFLICT_BACKUP" != "no" ]; then
if [ "$CONFLICT_BACKUP" != false ]; then
INITIATOR_BACKUP="--backup --backup-dir=\"${INITIATOR[$__backupDir]}\""
TARGET_BACKUP="--backup --backup-dir=\"${TARGET[$__backupDir]}\""
if [ "$CONFLICT_BACKUP_MULTIPLE" == "yes" ]; then
if [ "$CONFLICT_BACKUP_MULTIPLE" == true ]; 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)"
fi
@ -2689,7 +2711,7 @@ function Main {
function Usage {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$IS_STABLE" != "yes" ]; then
if [ "$IS_STABLE" != true ]; then
echo -e "\e[93mThis is an unstable dev build. Please use with caution.\e[0m"
fi
@ -2853,8 +2875,8 @@ DESTINATION_MAILS=""
INITIATOR_LOCK_FILE_EXISTS=false
TARGET_LOCK_FILE_EXISTS=false
FORCE_UNLOCK=false
LOG_CONFLICTS="no"
ALERT_CONFLICTS="no"
LOG_CONFLICTS=false
ALERT_CONFLICTS=false
no_maxtime=false
opts=""
ERROR_ALERT=false
@ -2863,11 +2885,11 @@ WARN_ALERT=false
SOFT_STOP=2
# Number of given replicas in command line
_QUICK_SYNC=0
_SYNC_ON_CHANGES="no"
_SYNC_ON_CHANGES=false
_NOLOCKS=false
osync_cmd=$0
_SUMMARY=false
INITIALIZE="no"
INITIALIZE=false
if [ "$MIN_WAIT" == "" ]; then
MIN_WAIT=60
fi
@ -2902,7 +2924,7 @@ function GetCommandlineArguments {
opts=$opts" --stats"
;;
--partial)
PARTIAL="yes"
PARTIAL=true
opts=$opts" --partial"
;;
--force-unlock)
@ -2968,16 +2990,16 @@ function GetCommandlineArguments {
_SUMMARY=true
;;
--log-conflicts)
LOG_CONFLICTS="yes"
LOG_CONFLICTS=true
opts=$opts" --log-conflicts"
;;
--alert-conflicts)
ALERT_CONFLICTS="yes"
LOG_CONFLICTS="yes"
ALERT_CONFLICTS=true
LOG_CONFLICTS=true
opts=$opts" --alert-conflicts"
;;
--initialize)
INITIALIZE="yes"
INITIALIZE=true
opts=$opts" --initialize"
;;
--no-prefix)
@ -3055,7 +3077,7 @@ if [ $_QUICK_SYNC -eq 2 ]; then
# First character shouldn't be '-' when config file given
elif [ "${1:0:1}" != "-" ]; then
ConfigFile="${1}"
LoadConfigFile "$ConfigFile"
LoadConfigFile "$ConfigFile" $CONFIG_FILE_REVISION_REQUIRED
else
Logger "Wrong arguments given. Expecting a config file or initiator and target arguments." "CRITICAL"
exit 1
@ -3078,7 +3100,7 @@ else
Logger "Script begin, logging to [$LOG_FILE]." "DEBUG"
fi
if [ "$IS_STABLE" != "yes" ]; then
if [ "$IS_STABLE" != true ]; then
Logger "This is an unstable dev build [$PROGRAM_BUILD]. Please use with caution." "WARN"
fi
@ -3092,13 +3114,16 @@ PostInit
# Add exclusion of $INITIATOR[$__updateTriggerFile] to rsync patterns used by sync functions, but not by daemon
RSYNC_FULL_PATTERNS="$RSYNC_PATTERNS --exclude=${INITIATOR[$__updateTriggerFile]}"
# v2 config syntax compatibility
UpdateBooleans
if [ $_QUICK_SYNC -lt 2 ]; then
if [ "$_SYNC_ON_CHANGES" == "no" ]; then
if [ "$_SYNC_ON_CHANGES" == false ]; then
CheckCurrentConfig true
else
CheckCurrentConfig false
fi
fi
CheckCurrentConfigAll
DATE=$(date)
Logger "-------------------------------------------------------------" "NOTICE"
@ -3119,7 +3144,7 @@ else
CheckReplicas
RunBeforeHook
if [ "$INITIALIZE" == "yes" ]; then
if [ "$INITIALIZE" == true ]; then
HandleLocks
Initialize
else
@ -3130,7 +3155,7 @@ else
if [ $_SUMMARY == true ]; then
Summary
fi
if [ $LOG_CONFLICTS == "yes" ]; then
if [ $LOG_CONFLICTS == true ]; then
LogConflicts
fi
fi

@ -1,5 +1,5 @@
#!/usr/bin/env bash
## Generic and highly portable bash functions written in 2013-2018 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## Generic and highly portable bash functions written in 2013-2019 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
#TODO: ExecTasks postponed arrays / files grow a lot. Consider having them "rolling" (cleaned at numberOfEvents)
#TODO: command line arguments don't take -AaqV for example
@ -31,7 +31,7 @@
#### OFUNCTIONS MINI SUBSET ####
#### OFUNCTIONS MICRO SUBSET ####
_OFUNCTIONS_VERSION=2.3.0-RC2
_OFUNCTIONS_BUILD=2018122103
_OFUNCTIONS_BUILD=20190110
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
_OFUNCTIONS_BOOTSTRAP=true
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
@ -66,12 +66,12 @@ WARN_ALERT=false
#### DEBUG SUBSET ####
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ];then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == true ];then #__WITH_PARANOIA_DEBUG
_DEBUG=yes #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG
## allow debugging from command line with _DEBUG=yes
if [ ! "$_DEBUG" == "yes" ]; then
if [ ! "$_DEBUG" == true ]; then
_DEBUG=no
_LOGGER_VERBOSE=false
else
@ -226,19 +226,19 @@ function RemoteLogger {
if [ "$level" == "CRITICAL" ]; then
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then
if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
elif [ "$level" == "ERROR" ]; then
_Logger "" "$prefix\e[31m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then
if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
elif [ "$level" == "WARN" ]; then
_Logger "" "$prefix\e[33m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then
if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
@ -256,12 +256,12 @@ function RemoteLogger {
_Logger "" "$prefix$value"
return
elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == "yes" ]; then
if [ "$_DEBUG" == true ]; then
_Logger "" "$prefix$value"
return
fi
elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == true ]; then #__WITH_PARANOIA_DEBUG
_Logger "" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG
return #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG
@ -337,12 +337,12 @@ function Logger {
_Logger "$prefix$value" "$prefix$value"
return
elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == "yes" ]; then
if [ "$_DEBUG" == true ]; then
_Logger "$prefix$value" "$prefix$value"
return
fi
elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == true ]; then #__WITH_PARANOIA_DEBUG
_Logger "$prefix$value" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG
return #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG
@ -451,7 +451,7 @@ function KillAllChilds {
#### CleanUp SUBSET ####
function CleanUp {
if [ "$_DEBUG" != "yes" ]; then
if [ "$_DEBUG" != true ]; then
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
@ -494,7 +494,7 @@ function SendAlert {
return 0
fi
if [ "$_DEBUG" == "yes" ]; then
if [ "$_DEBUG" == true ]; then
Logger "Debug mode, no warning mail will be sent." "NOTICE"
return 0
fi
@ -756,7 +756,7 @@ function LoadConfigFile {
else
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
revisionPresent=0
Logger "CONFIG_FILE_REVISION does not seem numeric [$revisionPresent]." "DEBUG"
fi
if [ "$revisionRequired" != "" ]; then
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
@ -898,7 +898,7 @@ function ExecTasks {
Logger "${FUNCNAME[0]} id [$id] called by [${FUNCNAME[1]} < ${FUNCNAME[2]} < ${FUNCNAME[3]} < ${FUNCNAME[4]} < ${FUNCNAME[5]} < ${FUNCNAME[6]} ...]." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
# Since ExecTasks takes up to 17 arguments, do a quick preflight check in DEBUG mode
if [ "$_DEBUG" == "yes" ]; then
if [ "$_DEBUG" == true ]; then
declare -a booleans=(readFromFile counting spinner noTimeErrorLog noErrorLogsAtAll)
for i in "${booleans[@]}"; do
test="if [ \$$i != false ] && [ \$$i != true ]; then Logger \"Bogus $i value [\$$i] given to ${FUNCNAME[0]}.\" \"CRITICAL\"; exit 1; fi"
@ -1145,7 +1145,7 @@ function ExecTasks {
# Trivial wait time for bash to not eat up all CPU
sleep $sleepTime
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG
if [ "$_PERF_PROFILER" == true ]; then ##__WITH_PARANOIA_DEBUG
_PerfProfiler ##__WITH_PARANOIA_DEBUG
fi ##__WITH_PARANOIA_DEBUG
@ -1512,7 +1512,7 @@ function GetLocalOS {
LOCAL_OS="BusyBox"
;;
*)
if [ "$IGNORE_OS_TYPE" == "yes" ]; then
if [ "$IGNORE_OS_TYPE" == true ]; then
Logger "Running on unknown local OS [$localOsVar]." "WARN"
return
fi
@ -1570,7 +1570,7 @@ function GetLocalOS {
function __CheckArguments {
# Checks the number of arguments of a function and raises an error if some are missing
if [ "$_DEBUG" == "yes" ]; then
if [ "$_DEBUG" == true ]; then
local numberOfArguments="${1}" # Number of arguments the tested function should have, can be a number of a range, eg 0-2 for zero to two arguments
local numberOfGivenArguments="${2}" # Number of arguments that have been passed
@ -1627,7 +1627,7 @@ function __CheckArguments {
function GetRemoteOS {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
return 0
fi
@ -1744,7 +1744,7 @@ ENDSSH
exit 1
;;
*)
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented debug only setting
if [ "$IGNORE_OS_TYPE" == true ]; then #DOC: Undocumented debug only setting
Logger "Running on unknown remote OS [$remoteOsVar]." "WARN"
return
fi
@ -1784,7 +1784,7 @@ function RunLocalCommand {
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
fi
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
Logger "Stopping on command execution error." "CRITICAL"
exit 1
fi
@ -1797,7 +1797,7 @@ function RunRemoteCommand {
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" != "yes" ]; then
if [ "$REMOTE_OPERATION" != true ]; then
Logger "Ignoring remote command [$command] because remote host is not configured." "WARN"
return 0
fi
@ -1827,7 +1827,7 @@ function RunRemoteCommand {
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
fi
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
Logger "Stopping on command execution error." "CRITICAL"
exit 1
fi
@ -1878,9 +1878,9 @@ function CheckConnectivityRemoteHost {
local retval
if [ "$_PARANOIA_DEBUG" != "yes" ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then
if [ "$REMOTE_HOST_PING" != false ] && [ "$REMOTE_OPERATION" != false ]; then
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
#ExecTasks "${FUNCNAME[0]}" 0 0 60 180 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
@ -1900,7 +1900,7 @@ function CheckConnectivity3rdPartyHosts {
local retval
local i
if [ "$_PARANOIA_DEBUG" != "yes" ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then
remote3rdPartySuccess=false
@ -2013,14 +2013,14 @@ function PreInit {
local compressionString
## SSH compression
if [ "$SSH_COMPRESSION" != "no" ]; then
if [ "$SSH_COMPRESSION" != false ]; then
SSH_COMP=-C
else
SSH_COMP=
fi
## Ignore SSH known host verification
if [ "$SSH_IGNORE_KNOWN_HOSTS" == "yes" ]; then
if [ "$SSH_IGNORE_KNOWN_HOSTS" == true ]; then
SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
fi
@ -2030,7 +2030,7 @@ function PreInit {
fi
## Sudo execution option
if [ "$SUDO_EXEC" == "yes" ]; then
if [ "$SUDO_EXEC" == true ]; then
if [ "$RSYNC_REMOTE_PATH" != "" ]; then
RSYNC_PATH="sudo $RSYNC_REMOTE_PATH/$RSYNC_EXECUTABLE"
else
@ -2194,19 +2194,19 @@ function InitRemoteOSDependingSettings {
fi
RSYNC_ATTR_ARGS=""
if [ "$PRESERVE_PERMISSIONS" != "no" ]; then
if [ "$PRESERVE_PERMISSIONS" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -p"
fi
if [ "$PRESERVE_OWNER" != "no" ]; then
if [ "$PRESERVE_OWNER" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -o"
fi
if [ "$PRESERVE_GROUP" != "no" ]; then
if [ "$PRESERVE_GROUP" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -g"
fi
if [ "$PRESERVE_EXECUTABILITY" != "no" ]; then
if [ "$PRESERVE_EXECUTABILITY" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" --executability"
fi
if [ "$PRESERVE_ACL" == "yes" ]; then
if [ "$PRESERVE_ACL" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ] && [ "$LOCAL_OS" != "Android" ] && [ "$REMOTE_OS" != "Android" ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -A"
else
@ -2214,45 +2214,45 @@ function InitRemoteOSDependingSettings {
fi
fi
if [ "$PRESERVE_XATTR" == "yes" ]; then
if [ "$PRESERVE_XATTR" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -X"
else
Logger "Disabling extended attributes synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
fi
fi
if [ "$RSYNC_COMPRESS" == "yes" ]; then
if [ "$RSYNC_COMPRESS" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -zz --skip-compress=gz/xz/lz/lzma/lzo/rz/jpg/mp3/mp4/7z/bz2/rar/zip/sfark/s7z/ace/apk/arc/cab/dmg/jar/kgb/lzh/lha/lzx/pak/sfx"
else
Logger "Disabling compression skips on synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
fi
fi
if [ "$COPY_SYMLINKS" == "yes" ]; then
if [ "$COPY_SYMLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -L"
fi
if [ "$KEEP_DIRLINKS" == "yes" ]; then
if [ "$KEEP_DIRLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -K"
fi
if [ "$RSYNC_OPTIONAL_ARGS" != "" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" "$RSYNC_OPTIONAL_ARGS
fi
if [ "$PRESERVE_HARDLINKS" == "yes" ]; then
if [ "$PRESERVE_HARDLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -H"
fi
if [ "$CHECKSUM" == "yes" ]; then
if [ "$CHECKSUM" == true ]; then
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --checksum"
fi
if [ "$BANDWIDTH" != "" ] && [ "$BANDWIDTH" != "0" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --bwlimit=$BANDWIDTH"
fi
if [ "$PARTIAL" == "yes" ]; then
if [ "$PARTIAL" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --partial --partial-dir=\"$PARTIAL_DIR\""
RSYNC_PARTIAL_EXCLUDE="--exclude=\"$PARTIAL_DIR\""
fi
if [ "$DELTA_COPIES" != "no" ]; then
if [ "$DELTA_COPIES" != false ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --no-whole-file"
else
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --whole-file"

@ -2,9 +2,10 @@
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v1.2x config file rev 2017060501
## ---------- GENERAL OPTIONS
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="local"
@ -27,7 +28,7 @@ SSH_PASSWORD_FILE=""
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist
CREATE_DIRS=no
CREATE_DIRS=false
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
@ -39,7 +40,7 @@ MINIMUM_SPACE=10240
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
@ -64,23 +65,23 @@ RSYNC_EXCLUDE_FROM=""
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
[REMOTE_OPTIONS]
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
SSH_IGNORE_KNOWN_HOSTS=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## ---------- MISC OPTIONS
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 -zz skip-compress checksum bwlimit partial partial-dir no-whole-file whole-file backup backup-dir suffix
@ -88,27 +89,27 @@ REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes
PRESERVE_OWNER=yes
PRESERVE_GROUP=yes
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=yes
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=yes
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
@ -125,45 +126,45 @@ MIN_WAIT=60
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files
LOG_CONFLICTS=yes
LOG_CONFLICTS=true
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=no
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## ---------- RESUME OPTIONS
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=yes
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
DELTA_COPIES=true
## ---------- ALERT OPTIONS
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
@ -187,7 +188,7 @@ SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
@ -201,7 +202,7 @@ MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no
RUN_AFTER_CMD_ON_ERROR=false

@ -2,9 +2,10 @@
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v1.2x config file rev 2017060601
## ---------- GENERAL OPTIONS
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="remote"
@ -15,7 +16,7 @@ INITIATOR_SYNC_DIR="${HOME}/osync-tests/initiator"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
#TARGET_SYNC_DIR="${HOME}/osync-tests/target"
TARGET_SYNC_DIR="ssh://root@localhost:49999/${HOME}/osync-tests/target"
TARGET_SYNC_DIR="ssh://root@localhost:44999/${HOME}/osync-tests/target"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local"
@ -27,7 +28,7 @@ SSH_PASSWORD_FILE=""
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist
CREATE_DIRS=no
CREATE_DIRS=false
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
@ -39,7 +40,7 @@ MINIMUM_SPACE=10240
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
@ -64,23 +65,23 @@ RSYNC_EXCLUDE_FROM=""
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
[REMOTE_OPTIONS]
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
SSH_IGNORE_KNOWN_HOSTS=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=yes
REMOTE_HOST_PING=true
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## ---------- MISC OPTIONS
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 -zz skip-compress checksum bwlimit partial partial-dir no-whole-file whole-file backup backup-dir suffix
@ -88,27 +89,27 @@ REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes
PRESERVE_OWNER=yes
PRESERVE_GROUP=yes
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=yes
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=yes
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
@ -125,45 +126,45 @@ MIN_WAIT=60
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files
LOG_CONFLICTS=yes
LOG_CONFLICTS=true
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=no
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## ---------- RESUME OPTIONS
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=yes
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
DELTA_COPIES=true
## ---------- ALERT OPTIONS
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
@ -187,7 +188,7 @@ SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
@ -201,7 +202,7 @@ MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no
RUN_AFTER_CMD_ON_ERROR=false

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# osync test suite 2019010201
# osync test suite 2019011001
# Allows the following environment variables
@ -66,7 +66,7 @@ TMP_OLD_CONF="tmp.old.conf"
OSYNC_EXECUTABLE="$FAKEROOT/usr/local/bin/osync.sh"
OSYNC_DEV_EXECUTABLE="dev/n_osync.sh"
OSYNC_UPGRADE="upgrade-v1.0x-v1.2x.sh"
OSYNC_UPGRADE="upgrade-v1.0x-v1.3x.sh"
TMP_FILE="$DEV_DIR/tmp"
@ -181,21 +181,21 @@ function oneTimeSetUp () {
if [ "$TRAVIS_RUN" == true ]; then
echo "Running with travis settings"
REMOTE_USER="travis"
RHOST_PING="no"
RHOST_PING=false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_3RD_PARTY_HOSTS" ""
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_HOST_PING" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_HOST_PING" false
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_3RD_PARTY_HOSTS" ""
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_HOST_PING" "no"
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_HOST_PING" false
else
echo "Running with local settings"
REMOTE_USER="root"
RHOST_PING="yes"
RHOST_PING=true
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_3RD_PARTY_HOSTS" "\"www.kernel.org www.google.com\""
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_HOST_PING" "yes"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_HOST_PING" true
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_3RD_PARTY_HOSTS" "\"www.kernel.org www.google.com\""
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_HOST_PING" "yes"
SetConfFileValue "$CONF_DIR/$OLD_CONF" "REMOTE_HOST_PING" true
fi
# Get default ssh port from env
@ -256,14 +256,14 @@ function oneTimeSetUp () {
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "SKIP_DELETION" ""
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "SKIP_DELETION" ""
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "COPY_SYMLINKS" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "COPY_SYMLINKS" "no"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "COPY_SYMLINKS" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "COPY_SYMLINKS" false
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" "no"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" false
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" "no"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "SOFT_MAX_EXEC_TIME" "7200"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "HARD_MAX_EXEC_TIME" "10600"
@ -318,11 +318,11 @@ function test_Merge () {
# Don't use SetConfFileValue here since for whatever reason Travis does not like creating a sed temporary file in $FAKEROOT
if [ "$TRAVIS_RUN" == true ]; then
$SUDO_CMD sed -i.tmp 's/^IS_STABLE=.*/IS_STABLE=yes/' "$OSYNC_EXECUTABLE"
$SUDO_CMD sed -i.tmp 's/^IS_STABLE=.*/IS_STABLE=true/' "$OSYNC_EXECUTABLE"
else
sed -i.tmp 's/^IS_STABLE=.*/IS_STABLE=yes/' "$OSYNC_EXECUTABLE"
sed -i.tmp 's/^IS_STABLE=.*/IS_STABLE=true/' "$OSYNC_EXECUTABLE"
fi
#SetConfFileValue "$OSYNC_EXECUTABLE" "IS_STABLE" "yes"
#SetConfFileValue "$OSYNC_EXECUTABLE" "IS_STABLE" true
assertEquals "Install failed" "0" $?
@ -573,7 +573,7 @@ function test_handle_symlinks () {
fi
# Check with and without copySymlinks
copySymlinks="no"
copySymlinks=false
echo "Running with COPY_SYMLINKS=$copySymlinks"
@ -660,7 +660,7 @@ function test_handle_symlinks () {
fi
# Check with and without copySymlinks
copySymlinks="yes"
copySymlinks=true
echo "Running with COPY_SYMLINKS=$copySymlinks"
@ -938,8 +938,8 @@ function test_MultipleConflictBackups () {
local additionalParameters
# modify config files
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" "yes"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" "yes"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" true
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" true
if [ "$OSYNC_MIN_VERSION" != "1" ]; then
additionalParameters="--errors-only --summary --no-prefix"
@ -991,8 +991,8 @@ function test_MultipleConflictBackups () {
assertEquals "3 Backup files are present in [$TARGET_DIR/$OSYNC_BACKUP_DIR/]." "0" $?
done
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" "no"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "CONFLICT_BACKUP_MULTIPLE" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" false
}
function test_Locking () {
@ -1083,8 +1083,8 @@ function test_Locking () {
# Target lock present should be resumed if instance ID is NOT the same as current one but FORCE_STRANGER_UNLOCK=yes
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" "yes"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" "yes"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" true
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" true
for i in "${osyncParameters[@]}"; do
@ -1098,8 +1098,8 @@ function test_Locking () {
assertEquals "Should be able to resume when target has lock with different instance id but FORCE_STRANGER_UNLOCK=yes." "0" $?
done
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" "no"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" "no"
SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "FORCE_STRANGER_LOCK_RESUME" false
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" false
}
function nope_test_ConflictDetetion () {

@ -1,10 +1,8 @@
#!/usr/bin/env bash
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2017 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v1.2x config file rev 2017060501
###### (C) 2013-2019 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v2.0x config file rev 2019011001
## ---------- GENERAL OPTIONS
[GENERAL]
## Sync job identification
INSTANCE_ID="sync_test"
@ -26,8 +24,8 @@ SSH_PASSWORD_FILE=""
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist
CREATE_DIRS=no
## Create sync directories if they do not exist (true/false)
CREATE_DIRS=true
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
@ -39,7 +37,7 @@ MINIMUM_SPACE=10240
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
@ -64,23 +62,23 @@ RSYNC_EXCLUDE_FROM=""
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
[REMOTE_OPTIONS]
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
SSH_IGNORE_KNOWN_HOSTS=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## ---------- MISC OPTIONS
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 -zz skip-compress checksum bwlimit partial partial-dir no-whole-file whole-file backup backup-dir suffix
@ -89,27 +87,27 @@ REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes
PRESERVE_OWNER=yes
PRESERVE_GROUP=yes
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can handle ACL. Disabled on Mac OSX.
PRESERVE_ACL=no
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage identical XATTRS. Disabled on Mac OSX. Apparently, prior to rsync v3.1.2 there are some performance caveats with transferring XATTRS.
PRESERVE_XATTR=no
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs. Be careful as symlinks without referrent will break sync as if standard files could not be copied.
COPY_SYMLINKS=no
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
@ -126,45 +124,45 @@ MIN_WAIT=60
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files
LOG_CONFLICTS=yes
LOG_CONFLICTS=true
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=no
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## ---------- RESUME OPTIONS
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=yes
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
DELTA_COPIES=true
## ---------- ALERT OPTIONS
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
@ -184,11 +182,11 @@ SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_ENCRYPTION=falsene
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
@ -202,7 +200,7 @@ MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no

Loading…
Cancel
Save