[lug] help with the infamous rsync include/exclude patterns
Davide Del Vento
davide.del.vento at gmail.com
Fri May 13 11:21:57 MDT 2016
I have this question at
if you prefer to answer there. Otherwise keep reading
I need to rsync some directories from one machine to another, but only
part of the tree. I think the easiest way to explain it would be to
run, on the server, tree -f (which prints the full path of each file)
and then grep'ing mon in the full path and rsynch'ing only the matches
of grep. Actually I would be happy to do it that way, but I don't have
shell access to the server, only rsync. Two step solution based on
greping output of rsync --list-only is totally acceptable.
It's actually simpler, because I also know that this mon appears only
as a suffix to a directory (the hierarchy is pretty rigid), so I tried
rsync --dry-run -vrlpt --include='*/' --include='**/*mon/'
but that did not match anything. Ditto for --include='*mon/' instead
of the one with the double asterisk. Avoiding the --prune-empty-dirs
matched all the directories but no files, which I think is my problem.
So I tried to add an include pattern for some file extensions right
before the exclude pattern (which I would rather not do because I
don't want to track them all and they might change), but that simply
matched all those files, including the ones not in the "mon" trees.
And yes, I did see countless examples of people doing similar stuff,
which helped me making some progress (i.e. what you can see above),
but not solve the problem...
More information about the LUG