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 grep
ing 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 doing
rsync --dry-run -vrlpt --include='*/' --include='**/*mon/' --exclude='*' --prune-empty-dirs
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 this and this and this and countless others, which helped me making some progress (i.e. what you can see above), but not solve the problem...