I a using rsync include successfully if the file is in the root of the source location but not if it is in a directory
This works:
rsync -aP --omit-dir-times \
-e 'ssh -p100 -i /home/me/.ssh/id_rsa.pub' \
--include fixed.xml --include file2.txt \
--exclude * \
/home/me/Desktop/test/ [email protected]:here/
This does not:
rsync -aP --omit-dir-times \
-e 'ssh -p100 -i /home/me/.ssh/id_rsa.pub' \
--include fixed.xml --include 50/200/file2.txt \
--exclude * \
/home/me/Desktop/test/ [email protected]:here/
Has anyone seen this issue before?
This case is actually described with examples in the rsync man page.
The solution is include the directories up the file you want:
--include 50 --include 50/200 --include 50/200/file2.txt
If this happens a lot then you can just add this, which is a shorter command but will force rsync to scan a lot of directories you don't care about:
--include '*/' --prune-empty-dirs --include 50/200/file2.txt
The prune is required to prevent it creating the whole directory structure, minus files, but should be used with care.