4

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/ \
   root@lambda2:/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/ \
    root@lambda2:/0ale/

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

alessandro
  • 41
  • 1
  • 2
  • 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. – user Aug 15 '11 at 09: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

2 Answers2

3

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/ \
   root@lambda2:/0ale/
Caleb
  • 69,278
  • 18
  • 196
  • 226
0

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/
TrinitronX
  • 904
  • 8
  • 15