Specify RULE file with either "--include-from" or "--exclude-from". They are the same.
The RULEs include:
The RULE and pattern should be separated by either a space or an underscore.
Include parent directories before including
If the parent directories are excluded, rsync will never look into it, so even if you include a file or directory under it, the file or directory will never be included. For example:
The file c.txt will never be included, since its parent directory b is excluded, and rsync will just ignore b and its children wholy.
It is assumed that all files and directories are included. So you always need to put "- *" in the last to exclude all unspecified. Some suggests to use "--filter=-! */", which means excluding all non-directories ("!" means non, and "*/" means all directories), which is to say, all the directories in current working path will be included. In order to prevent including empty directories, it is suggested to add the option "--prune-empty-dirs".
With recent rsync, there comes the p modifier. A p modifier to a rule indicates that the rule is perishable, or, it is ignored in directories that are being removed. The common usage is to handle with the ".DS_Store" file. The text "--filter='-p .DS_Store'" tells rsync to exclude ".DS_Store" unless the file is the last file in a directory, so that removing the near empty directory will not be hindered by the file.
Hide rules and delete
This page says a combination of hide and protect rules equals to an exclude rule:
#combined hide and protect
--filter='H /some/dir' --filter='P /some/dir'
- -a, --archive, same as -rlptgoD.
- -l, --links, copy symlinks as symlinks.
- -p, --perms, preserve permissions.
- -t, --times, preserve times.
- -g, --group, preserve group.
- -o, --owner, preserve owner (super-user only).
- -D, same as --devices --specials.
- --devices preserve device files (super-user only).
- --specials preserve special files.
- --delete, delete extraneous files from dest dirs.
- --delete-excluded, also delete excluded files from dest dirs.
- --exclude=PATTERN exclude files matching PATTERN.
- --exclude-from=FILE read exclude patterns from FILE.
- --partial, keep partially transferred files.
- -u, --update, skip files that are newer on the receiver.
- -R, --relative, use relative path names.
- -b, --backup, make backups (see --suffix & --backup-dir).
- --backup-dir=DIR, make backups into hierarchy based in DIR.
- --suffix=SUFFIX, backup suffix (default ~ w/o --backup-dir).
- -m, --prune-empty-dirs, prune empty directory chains from file-list.
- --numeric-ids, don't map uid/gid values by user/group name.
- -C, --cvs-exclude, auto-ignore files in the same way CVS does.
- -h, --human-readable, output numbers in a human-readable format.
- --progress, show progress during transfer.
About CVS exclude
The exclude list is initialized to:
RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj
*.so *.exe *.Z *.elc *.ln core .svn/
then files listed in a $HOME/.cvsignore are added to the list and any files listed in the CVSIGNORE environment variable (all cvsignore names are delimited by
Finally, any file is ignored if it is in the same directory as a .cvsignore file and matches one of the patterns listed therein. Unlike rsync's fil-
ter/exclude files, these patterns are split on whitespace.
rsync -avzCh --partial --progress src [email protected]:/path/to/des