mirror of https://github.com/deajan/osync.git
Finished work on include / exclude lists
parent
4398c02f9d
commit
b4159c1b02
|
@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
||||||
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.1-pre
|
PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BUILD=2015112702
|
PROGRAM_BUILD=2015112801
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
FUNC_BUILD=2015111901
|
FUNC_BUILD=2015111901
|
||||||
|
@ -1136,8 +1136,9 @@ function CheckDiskSpace {
|
||||||
|
|
||||||
function RsyncPatternsAdd {
|
function RsyncPatternsAdd {
|
||||||
local pattern="${1}"
|
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
|
# Disable globbing so wildcards from exclusions do not get expanded
|
||||||
set -f
|
set -f
|
||||||
|
@ -1154,9 +1155,9 @@ function RsyncPatternsAdd {
|
||||||
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
||||||
fi
|
fi
|
||||||
if [ "$RSYNC_PATTERNS" == "" ]; then
|
if [ "$RSYNC_PATTERNS" == "" ]; then
|
||||||
RSYNC_PATTERNS="--exclude=\"$str\""
|
RSYNC_PATTERNS="--"$pattern_type"=\"$str\""
|
||||||
else
|
else
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
set +f
|
set +f
|
||||||
|
@ -1164,8 +1165,9 @@ function RsyncPatternsAdd {
|
||||||
|
|
||||||
function RsyncPatternsFromAdd {
|
function RsyncPatternsFromAdd {
|
||||||
local pattern_from="${1}"
|
local pattern_from="${1}"
|
||||||
|
local pattern_type="${2}"
|
||||||
|
|
||||||
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
if [ ! "$pattern_from" == "" ]; then
|
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
|
## 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
|
fi
|
||||||
|
|
||||||
if [ -e "$pattern_from" ]; then
|
if [ -e "$pattern_from" ]; then
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1183,15 +1185,15 @@ function RsyncPatterns {
|
||||||
__CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include"
|
||||||
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include"
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
else
|
else
|
||||||
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
||||||
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.1-pre
|
PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BUILD=2015112702
|
PROGRAM_BUILD=2015112801
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
source "./ofunctions.sh"
|
source "./ofunctions.sh"
|
||||||
|
@ -248,8 +248,9 @@ function CheckDiskSpace {
|
||||||
|
|
||||||
function RsyncPatternsAdd {
|
function RsyncPatternsAdd {
|
||||||
local pattern="${1}"
|
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
|
# Disable globbing so wildcards from exclusions do not get expanded
|
||||||
set -f
|
set -f
|
||||||
|
@ -266,9 +267,9 @@ function RsyncPatternsAdd {
|
||||||
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
||||||
fi
|
fi
|
||||||
if [ "$RSYNC_PATTERNS" == "" ]; then
|
if [ "$RSYNC_PATTERNS" == "" ]; then
|
||||||
RSYNC_PATTERNS="--exclude=\"$str\""
|
RSYNC_PATTERNS="--"$pattern_type"=\"$str\""
|
||||||
else
|
else
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
set +f
|
set +f
|
||||||
|
@ -276,8 +277,9 @@ function RsyncPatternsAdd {
|
||||||
|
|
||||||
function RsyncPatternsFromAdd {
|
function RsyncPatternsFromAdd {
|
||||||
local pattern_from="${1}"
|
local pattern_from="${1}"
|
||||||
|
local pattern_type="${2}"
|
||||||
|
|
||||||
__CheckArguments 1 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 2 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
if [ ! "$pattern_from" == "" ]; then
|
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
|
## 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
|
fi
|
||||||
|
|
||||||
if [ -e "$pattern_from" ]; then
|
if [ -e "$pattern_from" ]; then
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -295,15 +297,15 @@ function RsyncPatterns {
|
||||||
__CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# $FUNCNAME "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include"
|
||||||
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include"
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
else
|
else
|
||||||
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
||||||
fi
|
fi
|
||||||
|
|
26
osync.sh
26
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"
|
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.1-pre
|
PROGRAM_VERSION=1.1-pre
|
||||||
PROGRAM_BUILD=2015112702
|
PROGRAM_BUILD=2015112801
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
FUNC_BUILD=2015111901
|
FUNC_BUILD=2015111901
|
||||||
|
@ -1025,6 +1025,7 @@ function CheckDiskSpace {
|
||||||
|
|
||||||
function RsyncPatternsAdd {
|
function RsyncPatternsAdd {
|
||||||
local pattern="${1}"
|
local pattern="${1}"
|
||||||
|
local pattern_type="${2}" # exclude or include
|
||||||
|
|
||||||
|
|
||||||
# Disable globbing so wildcards from exclusions do not get expanded
|
# Disable globbing so wildcards from exclusions do not get expanded
|
||||||
|
@ -1042,9 +1043,9 @@ function RsyncPatternsAdd {
|
||||||
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
||||||
fi
|
fi
|
||||||
if [ "$RSYNC_PATTERNS" == "" ]; then
|
if [ "$RSYNC_PATTERNS" == "" ]; then
|
||||||
RSYNC_PATTERNS="--exclude=\"$str\""
|
RSYNC_PATTERNS="--"$pattern_type"=\"$str\""
|
||||||
else
|
else
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude=\"$str\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"=\"$str\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
set +f
|
set +f
|
||||||
|
@ -1052,6 +1053,7 @@ function RsyncPatternsAdd {
|
||||||
|
|
||||||
function RsyncPatternsFromAdd {
|
function RsyncPatternsFromAdd {
|
||||||
local pattern_from="${1}"
|
local pattern_from="${1}"
|
||||||
|
local pattern_type="${2}"
|
||||||
|
|
||||||
|
|
||||||
if [ ! "$pattern_from" == "" ]; then
|
if [ ! "$pattern_from" == "" ]; then
|
||||||
|
@ -1061,7 +1063,7 @@ function RsyncPatternsFromAdd {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$pattern_from" ]; then
|
if [ -e "$pattern_from" ]; then
|
||||||
RSYNC_PATTERNS="$RSYNC_PATTERNS --exclude-from=\"$pattern_from\""
|
RSYNC_PATTERNS="$RSYNC_PATTERNS --"$pattern_type"-from=\"$pattern_from\""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1069,15 +1071,15 @@ function RsyncPatternsFromAdd {
|
||||||
function RsyncPatterns {
|
function RsyncPatterns {
|
||||||
|
|
||||||
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
if [ "$RSYNC_PATTERN_ORDER" == "exclude" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_INCLUDE_FROM" "include"
|
||||||
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
elif [ "$RSYNC_PATTERN_ORDER" == "include" ]; then
|
||||||
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_INCLUDE_PATTERN" "include"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "include"
|
||||||
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN"
|
RsyncPatternsAdd "$RSYNC_EXCLUDE_PATTERN" "exclude"
|
||||||
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM"
|
RsyncPatternsFromAdd "$RSYNC_EXCLUDE_FROM" "exclude"
|
||||||
else
|
else
|
||||||
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
Logger "Bogus RSYNC_PATTERN_ORDER in config file" "WARN"
|
||||||
fi
|
fi
|
||||||
|
|
40
sync.conf
40
sync.conf
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
###### Osync - Rsync based two way sync engine with fault tolerance
|
###### Osync - Rsync based two way sync engine with fault tolerance
|
||||||
###### (L) 2013-2015 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
###### (L) 2013-2015 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
||||||
###### Config file rev 2015103001
|
###### Config file rev 2015112801
|
||||||
|
|
||||||
## ---------- GENERAL OPTIONS
|
## ---------- 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)
|
## 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=""
|
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.
|
## Generate an alert if initiator or target replicas have less free space than given value in KB.
|
||||||
MINIMUM_SPACE=10240
|
MINIMUM_SPACE=10240
|
||||||
|
|
||||||
|
@ -58,6 +39,25 @@ RSYNC_EXECUTABLE=rsync
|
||||||
## Remote rsync executable path. Leave this empty in most cases
|
## Remote rsync executable path. Leave this empty in most cases
|
||||||
RSYNC_REMOTE_PATH=""
|
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
|
## ---------- REMOTE SYNC OPTIONS
|
||||||
|
|
||||||
## ssh compression should be used unless your remote connection is good enough (LAN)
|
## ssh compression should be used unless your remote connection is good enough (LAN)
|
||||||
|
|
Loading…
Reference in New Issue