add option to exclude files or directories from a file and bug fix in tree_list

pull/3/head
Pierre CLEMENT 10 years ago
parent deb0058b6e
commit 5d374909d4

@ -0,0 +1,5 @@
.localized
.AppleDouble/
._*
.DS_Store
Thumbs.db

@ -735,6 +735,14 @@ function RsyncExcludePattern
IFS=$OLD_IFS
}
function RsyncExcludeFrom
{
if [ ! -z $RSYNC_EXCLUDE_FROM ] && [ -e $RSYNC_EXCLUDE_FROM ]
then
RSYNC_EXCLUDE="$RSYNC_EXCLUDE --exclude-from=\"$RSYNC_EXCLUDE_FROM\""
fi
}
function WriteLockFiles
{
echo $SCRIPT_PID > "$MASTER_LOCK"
@ -909,7 +917,7 @@ function tree_list
ESC=$(EscapeSpaces "$1")
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$ESC/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/osync_$2_$SCRIPT_PID\" &"
else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSNYC_EXCLUDE --list-only \"$1/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/osync_$2_$SCRIPT_PID\" &"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --list-only \"$1/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > \"$RUN_DIR/osync_$2_$SCRIPT_PID\" &"
fi
LogDebug "RSYNC_CMD: $rsync_cmd"
## Redirect commands stderr here to get rsync stderr output in logfile
@ -1558,7 +1566,9 @@ function Init
fi
## Add Rsync exclude patterns
RsyncExcludePattern
RsyncExcludePattern
## Add Rsync exclude from file
RsyncExcludeFrom
}
function Main

@ -25,6 +25,9 @@ LOGFILE=""
## 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="tmp;archives"
## File that containes the list of directories or files to exclude from sync on both sides.
## Paths are relative to sync dirs. One element per line.
RSYNC_EXCLUDE_FROM="files.exclude"
## List elements separator char. You may set an alternative seperator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"

Loading…
Cancel
Save