Here's my "teach a person to fish" answer:
Rsync's syntax is definitely non-intuitive, but it is worth understanding.
-vvv
to see the debug info for rsync.$ rsync -nr -vvv --include="**/file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
[sender] hiding directory 1280000000 because of pattern *
[sender] hiding directory 1260000000 because of pattern *
[sender] hiding directory 1270000000 because of pattern *
The key concept here is that rsync applies the include/exclude patterns for each directory recursively. As soon as the first include/exclude is matched, the processing stops.
The first directory it evaluates is /Storage/uploads
. Storage/uploads
has 1280000000/, 1260000000/, 1270000000/
dirs/files. None of them match file_11*.jpg
to include. All of them match *
to exclude. So they are excluded, and rsync ends.
*/
) first. Then the first dir component will be 1260000000/, 1270000000/, 1280000000/
since they match */
. The next dir component will be 1260000000/
. In 1260000000/
, file_11_00.jpg
matches --include="file_11*.jpg"
, so it is included. And so forth.$ rsync -nrv --include='*/' --include="file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
./
1260000000/
1260000000/file_11_00.jpg
1260000000/file_11_01.jpg
1270000000/
1270000000/file_11_00.jpg
1270000000/file_11_01.jpg
1280000000/
1280000000/file_11_00.jpg
1280000000/file_11_01.jpg