Article 5GW6X How to do a relative rsync to include specified sub subdirectories but exclude everything else

How to do a relative rsync to include specified sub subdirectories but exclude everything else

by
Shaggy1
from LinuxQuestions.org on (#5GW6X)
System info:
Code:rsync version 3.1.2 protocol version 31

CentOS Linux release 7.6.1810 (Core)

Linux lb-cam-11 3.10.0-1062.1.1.el7.x86_64 #1 SMP Fri Sep 13 22:55:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Hi

I am trying to set up some relative rsyncs where I can list the directories and sub-directories I'd line to include, but exclude everything else.

I have a command that I thought did what I wanted, but it does not seem to allow me to specifically include only specified sub sub directories.

My test directory structure looks like:
Code:tstsyncsubdirs
---- file1.txt
---- jenkins
---- file3.txt
---- team
--------- bin
-------------- dir1
-------------- filr4.txt
--------- etc
-------------- dir3
-------------- filr6.txt
--------- file2.txt
--------- oss
-------------- dir2
-------------- filr5.txt
---- testIf I then use the following command to sync tstsyncsubdirs to /work/tstsync:
Code:$ /usr/bin/rsync -vv -e 'ssh -l username' -avRl --include="tstsyncsubdirs/team/***" --exclude='tstsyncsubdirs/*' username@hostname:/home/username/./tstsyncsubdirs /work/tstsyncThe rules list looks like:
Code:[sender] add_rule(+ tstsyncsubdirs/team/***)
[sender] add_rule(- tstsyncsubdirs/*)and it syncs just team and everything beneath it to /work/tstsync. Everything else is excluded
so it looks like '+ tstsyncsubdirs/team/***' is processed first and therefore overrides '- tstsyncsubdirs/*'
This is what I want and what I expected to happen.

However if I try to sync only the bin directory under team by doing this command:
Code:$ /usr/bin/rsync -vv -e 'ssh -l username' -avRl --include="tstsyncsubdirs/team/bin/***" --exclude='tstsyncsubdirs/*' username@hostname:/home/username/./tstsyncsubdirs /work/tstsyncThe rules list looks like:
Code:[sender] add_rule(+ tstsyncsubdirs/team/bin/***)
[sender] add_rule(- tstsyncsubdirs/*)But it filters out everything, nothing is sync'd.
So it looks like it does not translate '+ tstsyncsubdirs/team/bin/***' in the way I thought it would (which is to match team/bin and everything under it)

Does anyone know why tstsyncsubdirs/team/bin/*** does not match ?
Does anyone know how I can make it so I can include just the dirs and subdirs I require and exclude everything else ?
(The include list would be in a file pointed to by --include-from)latest?d=yIl2AUoC8zA latest?i=OgafWSn2rTE:yOeUgUL1M7E:F7zBnMy latest?i=OgafWSn2rTE:yOeUgUL1M7E:V_sGLiP latest?d=qj6IDK7rITs latest?i=OgafWSn2rTE:yOeUgUL1M7E:gIN9vFwOgafWSn2rTE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments