Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed the advice given in the question Rsync filter: copying one pattern only to setup a command line I need to backup only the dotfiles .inF*

Yet with the command:

rsync -av --include='.inF*' --include='*/' --exclude='*' /0ale/ \

I obtain that the directory structure gets mirrored, but no dotfile is copied. The same command with a test pattern

rsync -av --include='test*' --include='*/' --exclude='*' /0ale/ \

correctly copies the test1.txt file so it is a problem with dotfiles only. Any hints?

share|improve this question
Does perhaps the . at the beginning get treated as a merge directive rather than being seen as part of the file name? You may want to try + .inF* instead. Maybe use --filter with appropriate flags rather than include/exclude. See the rsync man page for details. – Michael Kjörling Aug 15 '11 at 9:43
@MichaelKjörling: A leading dot is only interpreted as a merge pattern flag if it is separated from the pattern by a space. – Caleb Aug 15 '11 at 11:29

The include/exclude filters in rsync are processed in the order in which they appear. In order to match a dot-file in a subdirectory (or any directory other than the current working directory of rsync) you need to place your */ include rule to include folders first, then your .* match to include dot-files.

rsync -av  --include='*/' --include='.inF*' --exclude='*' /0ale/ \
share|improve this answer

I had tried something similar to the answer above to copy dotfiles (pattern was: --include='.**' --exclude='*'), but found that some other excludes that I wanted were not actually being excluded.

If you have other --exclude= flags you want to pass, use the following pattern:

rsync  -avz --exclude='path/to/exclude1' --exclude='path/to/exclude2' --exclude='.Trash'  /0ale/.[^.]* root@lambda2:/0ale/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.