diff --git a/dev/debug_osync.sh b/dev/debug_osync.sh index f1cce51..9caad6f 100755 --- a/dev/debug_osync.sh +++ b/dev/debug_osync.sh @@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.1-pre -PROGRAM_BUILD=2015112702 +PROGRAM_BUILD=2015112801 IS_STABLE=no FUNC_BUILD=2015111901 @@ -1136,8 +1136,9 @@ function CheckDiskSpace { function RsyncPatternsAdd { local pattern="${1}" + local pattern_type="${2}" # exclude or include - __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG + __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG # Disable globbing so wildcards from exclusions do not get expanded set -f @@ -1154,9 +1155,9 @@ function RsyncPatternsAdd { rest=${rest#*$PATH_SEPARATOR_CHAR} fi if [ "$RSYNC_PATTERNS" == "" ]; then - RSYNC_PATTERNS="--exclude=\"$str\"" + RSYNC_PATTERNS="--"$pattern_type"=\"$str\"" else - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\"" fi done set +f @@ -1164,8 +1165,9 @@ function RsyncPatternsAdd { function RsyncPatternsFromAdd { local pattern_from="${1}" + local pattern_type="${2}" - __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG + __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG if [ ! "$pattern_from" == "" ]; then ## Check if the exclude list has a full path, and if not, add the config file path if there is one @@ -1174,7 +1176,7 @@ function RsyncPatternsFromAdd { fi if [ -e "$pattern_from" ]; then - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\"" fi fi } @@ -1183,15 +1185,15 @@ function RsyncPatterns { __CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include" elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" else Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN" fi diff --git a/dev/n_osync.sh b/dev/n_osync.sh index c139a73..6c4ffcf 100755 --- a/dev/n_osync.sh +++ b/dev/n_osync.sh @@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.1-pre -PROGRAM_BUILD=2015112702 +PROGRAM_BUILD=2015112801 IS_STABLE=no source "./ofunctions.sh" @@ -248,8 +248,9 @@ function CheckDiskSpace { function RsyncPatternsAdd { local pattern="${1}" + local pattern_type="${2}" # exclude or include - __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG + __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG # Disable globbing so wildcards from exclusions do not get expanded set -f @@ -266,9 +267,9 @@ function RsyncPatternsAdd { rest=${rest#*$PATH_SEPARATOR_CHAR} fi if [ "$RSYNC_PATTERNS" == "" ]; then - RSYNC_PATTERNS="--exclude=\"$str\"" + RSYNC_PATTERNS="--"$pattern_type"=\"$str\"" else - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\"" fi done set +f @@ -276,8 +277,9 @@ function RsyncPatternsAdd { function RsyncPatternsFromAdd { local pattern_from="${1}" + local pattern_type="${2}" - __CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG + __CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG if [ ! "$pattern_from" == "" ]; then ## Check if the exclude list has a full path, and if not, add the config file path if there is one @@ -286,7 +288,7 @@ function RsyncPatternsFromAdd { fi if [ -e "$pattern_from" ]; then - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\"" fi fi } @@ -295,15 +297,15 @@ function RsyncPatterns { __CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include" elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" else Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN" fi diff --git a/osync.sh b/osync.sh index f0dcffa..b57c870 100755 --- a/osync.sh +++ b/osync.sh @@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.1-pre -PROGRAM_BUILD=2015112702 +PROGRAM_BUILD=2015112801 IS_STABLE=no FUNC_BUILD=2015111901 @@ -1025,6 +1025,7 @@ function CheckDiskSpace { function RsyncPatternsAdd { local pattern="${1}" + local pattern_type="${2}" # exclude or include # Disable globbing so wildcards from exclusions do not get expanded @@ -1042,9 +1043,9 @@ function RsyncPatternsAdd { rest=${rest#*$PATH_SEPARATOR_CHAR} fi if [ "$RSYNC_PATTERNS" == "" ]; then - RSYNC_PATTERNS="--exclude=\"$str\"" + RSYNC_PATTERNS="--"$pattern_type"=\"$str\"" else - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\"" fi done set +f @@ -1052,6 +1053,7 @@ function RsyncPatternsAdd { function RsyncPatternsFromAdd { local pattern_from="${1}" + local pattern_type="${2}" if [ ! "$pattern_from" == "" ]; then @@ -1061,7 +1063,7 @@ function RsyncPatternsFromAdd { fi if [ -e "$pattern_from" ]; then - RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\"" + RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\"" fi fi } @@ -1069,15 +1071,15 @@ function RsyncPatternsFromAdd { function RsyncPatterns { if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include" elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then - RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" - RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" - RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" + RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include" + RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude" + RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude" else Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN" fi diff --git a/sync.conf b/sync.conf index 79e7c3b..bd6302a 100644 --- a/sync.conf +++ b/sync.conf @@ -2,7 +2,7 @@ ###### Osync - Rsync based two way sync engine with fault tolerance ###### (L) 2013-2015 by Orsiris "Ozy" de Jong (www.netpower.fr) -###### Config file rev 2015103001 +###### Config file rev 2015112801 ## ---------- GENERAL OPTIONS @@ -26,25 +26,6 @@ CREATE_DIRS=no ## 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="" -## Rsync exclude / include order (the option here will be set first) -RSYNC_PATTERN_ORDER=exclude - -## List of directories to exclude from sync on both sides (rsync patterns, wildcards work). -## Paths are relative to sync dirs. List elements are separated by a semicolon. -RSYNC_EXCLUDE_PATTERN="" -#RSYNC_EXCLUDE_PATTERN="tmp;archives" -RSYNC_INCLUDE_PATTERN="" - -## File that contains the list of directories or files to exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file. -## This file has to be in the same directory as the config file -## Paths are relative to sync dirs. One element per line. -RSYNC_EXCLUDE_FROM="" -#RSYNC_EXCLUDE_FROM="exclude.list" -RSYNC_INCLUDE_FROM="" - -## List elements separator char. You may set an alternative separator char for your directories lists above. -PATH_SEPARATOR_CHAR=";" - ## Generate an alert if initiator or target replicas have less free space than given value in KB. MINIMUM_SPACE=10240 @@ -58,6 +39,25 @@ RSYNC_EXECUTABLE=rsync ## Remote rsync executable path. Leave this empty in most cases RSYNC_REMOTE_PATH="" +## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns) +RSYNC_PATTERN_FIRST=include + +## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work). +## Paths are relative to sync dirs. List elements are separated by a semicolon. +RSYNC_INCLUDE_PATTERN="" +RSYNC_EXCLUDE_PATTERN="" +#RSYNC_EXCLUDE_PATTERN="tmp;archives" + +## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file. +## This file has to be in the same directory as the config file +## Paths are relative to sync dirs. One element per line. +RSYNC_INCLUDE_FROM="" +RSYNC_EXCLUDE_FROM="" +#RSYNC_EXCLUDE_FROM="exclude.list" + +## List elements separator char. You may set an alternative separator char for your directories lists above. +PATH_SEPARATOR_CHAR=";" + ## ---------- REMOTE SYNC OPTIONS ## ssh compression should be used unless your remote connection is good enough (LAN)