All notes


Specify RULE file with either "--include-from" or "--exclude-from". They are the same.

The RULEs include:

+ include
- exclude
. merge
: dir-merge
H hide
S show
P protect
R risk
! clear
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:

+ b/c.txt
- *
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:

#exclude rule

#combined hide and protect
--filter='H /some/dir' --filter='P /some/dir'

Rsync FAQ

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 whitespace).

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