I'm trying hard to understand the rsync filter system, and it's completely baffling me.
I have the following "test" directory structure to try to make sense of it. With no filter options here are all my files:
rsync -amv --dry-run /source /target
building file list ... done
source/
source/1.pdf
source/2.pdf
source/exclude_rules.txt
source/filter_rules.txt
source/excludedir/
source/excludedir/2.jpg
source/excludedir/4.pdf
source/subdir/
source/subdir/1.jpg
source/subdir/1.txt
source/subdir/3.pdf
source/subdir/subdir2/
source/subdir/subdir2/6.jpg
source/subdir/subdir2/6.pdf
I just want to sync all *.pdf
files except in certain directories, namely any directory that has *exclude*
in it.
I'm using a file with the filter rules in it with the following command:
rsync -amv --dry-run --filter='merge /filter_rules' /source /target
The filter_rules look like variations on the following but I can't get them to produce the results I'm after:
-/ *exclude*/
+/ *.pdf
-/ *
The closest I've come is with the simple exclude:
-/ *exclude*/
Which yields:
building file list ... done
source/
source/1.pdf
source/2.pdf
source/exclude_rules.txt
source/filter_rules.txt
source/subdir/
source/subdir/1.jpg
source/subdir/1.txt
source/subdir/3.pdf
source/subdir/subdir2/
source/subdir/subdir2/6.jpg
source/subdir/subdir2/6.pdf
How do I filter the rest to just get *.pdf
?