I’m trying to exclude some directories and hidden directories from an rsync
process.
I noticed the following behaviour with rsync --exclude
flag:
The following excludes .git directory. ""
is essential.
rsync -av --exclude=".git" ./data ./scratch
The following excludes Test_Data directory
rsync -av --exclude=./data/Test_Data/ ./data ./scratch
However, combining the two includes Test_Data directory but still excludes .git directory
rsync -av --exclude=".git" --exclude=./data/Test_Data/ ./data ./scratch
Swapping the order still excludes .git directory and includes Test_Data
rsync -av --exclude="./data/Test_Data/" --exclude=".git" ./data ./scratch
I’ve tested variants of single ''
or double ""
or no quotes. I’ve also tested the syntax:
--exclude={"./data/Test_Data/",".git"}
and the performance is the same. What is the correct way to exclude both a hidden directory and a directory with rsync or is this not possible?