Score:0

rsync pattern to include all files of specific patterns and exclude the rest, from all subdirectory tree

I mean to rsync some files of a subdirectory tree at dir1.

I am using

[dir1]$ rsync --itemize-changes --recursive --update --times --include-from="rsync_include.dat" --exclude="*" --dry-run ./ remote:~/dir1/

The rules are as follow, in this order.

  1. Include subdirs dir11 and dir12 at level 1.
  2. Exclude the rest at level 1.
  3. Within dir11 and dir12, include all files *.cc, *.txt in the subtrees.
  4. Within dir11 and dir12, exclude all other files.
  5. Within dir11 and dir12, include some specific subtrees (at possibly various levels), with all their contents.

I am not hitting the nail in the head with the proper combinations of single, double and triple asterisks, plus/minus signs, trailing backslashes, and rules order in my rsync_include.dat.

What would the correct contents be?

Among all I tried, I am posting below the current state of my rsync_include.dat. Among others, it did not match file classes/src/TEST/classes_test.cc, which had a later date in ./ than in remote:~/dir1/, and therefore I want it to be rsynced. In this case, I am looking for a pattern that would match that file without me having to enter + classes/src/TEST/*.cc, since there might be other *.cc at various depths and branches.

+ classes/
+ sanitizers/
- ***/.cproject
+ **/*.cc
+ ***/*.cc
+ **/*.cpp
+ **/*.dat

- */
- **/
vanadium avatar
cn flag
It will depend on the contents of your `rsync_include.dat`, so nothing can be said unless you include the contents of that file. You also fail to mention how command you tried does not fulfill your expectations.
sancho.s ReinstateMonicaCellio avatar
@vanadium - I expanded the OP as requested. What I am asking about is precisely what is the correct contents of my `rsync_include.dat` to achieve my goal.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.