Rsync --Exclude Not Excluding Specific Files

rsync --exclude not excluding specific files

It turned out that it is the relative path from the folders that are being rsync'd with one another. Not from where you are running the rsync command.

--exclude "generator/" --exclude "server/lib/personas_constants.php" --exclude "server/lib/connect.php" 

Fixed my issues.

rsync include specific files and exclude directory

You need to put --exclude='build' before --include '*/'. Both of these rules could apply to the "build" directory, and whichever is given first takes precedence, so to get the --exclude rule to override the --include rule, you need to list it first.

From the rsync man page, in the FILTER RULES section (with my emphasis):

As the list of files/directories to transfer is built, rsync checks
each name to be transferred against the list of include/exclude
patterns in turn, and the first matching pattern is acted on: if it is
an exclude pattern, then that file is skipped; if it is an include
pattern then that filename is not skipped; if no matching pattern is
found, then the filename is not skipped.

rsync --exclude and --exclude-from not working

This should exclude Images folder:

rsync -avz --exclude 'Images' ./Dummy-dir/ ./Dummy-target/

should be relative to the source path without the source path

Make rsync exclude all directories that contain a file with a specific name

rsync does not support this (at least the manpage does not mention anything), but you can do it in two steps:

  1. run find to find the .rsync-exclude files
  2. pipe this list to --exclude-from (or use a temporary file)

       --exclude-from=FILE
    This option is related to the --exclude option, but it specifies a FILE that contains exclude patterns
    (one per line). Blank lines in the file and lines starting with ';' or '#' are ignored. If FILE is -,
    the list will be read from standard input.

alternatively, if you do not mind to put something in the files, you can use:

       -F     The -F option is a shorthand for adding two --filter rules to your command.  The first time it is  used
is a shorthand for this rule:

--filter='dir-merge /.rsync-filter'

This tells rsync to look for per-directory .rsync-filter files that have been sprinkled through the
hierarchy and use their rules to filter the files in the transfer. If -F is repeated, it is a short-
hand for this rule:

--filter='exclude .rsync-filter'

This filters out the .rsync-filter files themselves from the transfer.

See the FILTER RULES section for detailed information on how these options work.

rsync: How to apply a recursively include filter while excluding other files

Try first including folders themselves:

rsync -zarv \
--include="/*.html" \
--include="/js/" \
--include="/js/**/" \
--include="/js/**.min.js" \
--include="/js/**.min.js" \
--include="/js/**.min.js.map" \
--include="/css/" \
--include="/css/**/" \
--include="/css/**.min.css" \
--include="/css/**.min.css.map" \
--include="/img/***" \
--exclude="*" \
--delete \
./ "$to"/


Related Topics



Leave a reply



Submit