I am trying to use rsync to copy a specific set of subdirectories to back them up. My directory structure looks something like this:
/path/to/data/foo1 /path/to/data/foo2 /path/to/data/bar1 /path/to/data/bar2
I just want to copy the 'foo' folders, ignoring the 'bar' ones.
I also want to ignore any .zip files inside those folders.
I have tried many combinations of arguments in rsync, but can't get it to do exactly what I want.
I can do the transfer as I want to using two commands:
rsync --dry-run -a --human-readable --stats --progress --exclude"*.zip" "/path/to/data/foo1" "/mnt/backup/drive/" rsync --dry-run -a --human-readable --stats --progress --exclude"*.zip" "/path/to/data/foo2" "/mnt/backup/drive"
Form reading elsewhere, I expect something like this to work
rsync --dry-run -a --human-readable --stats --progress --include="data/foo*" --exclude="*.zip" --exclude="*" "/path/to/data" "/mnt/backup/drive"
But this also seems to capture the 'bar' folders.
The ordering of the --include and --exclude arguments is confusing me. As is the need to specify the 'data' folder in the --include argument is not the functionality I would expect.
What is the obvious flag that I'm missing!
Thanks for your input.