The man pages do not have examples for this. I am having a hard time telling rsync to only include some file where those files. I don't understand why you have to exclude in order to include, why the rsync just not include what ever is in the include file and that it, everything else will be excluded.
This is my script:
rsync -ruv --rsh=ssh --include-from=zz-rsync-test.prod.incl /usr2/subdir remoteSrv:/tmp/.and this is my include file which does not work: It copies too much: it copies every thing in the /usr2/subdir (including the subdir directory, weird) which I don't want. I want to copy only those per, 42f, and xml files in the data/text_forms directory.
+ data/text_forms/*.per
+ data/text_forms/*.42f
+ data/text_forms/*.xml
+ data/text_forms/*.xml.*and the following does not work, it does not copy anything:
- *
+ data/text_forms/*.per
+ data/text_forms/*.42f
+ data/text_forms/*.xml
+ data/text_forms/*.xml.*and the following does not work either, it does not copy anything:
- *
+ data/
+ data/text_forms/*.per
+ data/text_forms/*.42f
+ data/text_forms/*.xml
+ data/text_forms/*.xml.*and the following does not work either, it does not copy anything:
- *
+ data/
+ data/text_forms/
+ data/text_forms/*.per
+ data/text_forms/*.42f
+ data/text_forms/*.xml
+ data/text_forms/*.xml.*The following does not work either:
+ */
+ /data/text_forms/*.per
+ /data/text_forms/*.42f
+ /data/text_forms/*.xml
+ /data/text_forms/*.xml.*
- *Neither the following works:
+ /data/
+ /data/text_forms/
+ /data/text_forms/*.per
+ /data/text_forms/*.42f
+ /data/text_forms/*.xml
+ /data/text_forms/*.xml.*
- * 1 1 Answer
I found the solution. I took me two full days to find it. I hope this help you to not spend that much time.
The first problem was that the sub-directory subdir in /usr2/subdir was included and I did not wanted that whole directory to be included, I just wanted it to be the base directory, so it requires a slash at the end as in /usr2/subdir/, so my new command looks like:
rsync -ruvv --rsh=ssh --include-from=zz-rsync-test.prod.incl /usr2/subdir/ remoteSrv:/tmp/.Note that I added an extra v option in the command line (-ruvv) to get more detail of what was excluded or included at the moment of running the command. With the base directory fixed and the extra v it was a little easier to built the right include file:
+ data/
+ data/text_forms/
+ data/text_forms/*.per
+ data/text_forms/*.42f
+ data/text_forms/*.xml
+ data/text_forms/*.xml.*
- *All the + lines have to be placed before the - *, specially for directories as I had to explicitly include each directory to scan even if I don't want to get files directly inside those directories. I did a test adding a data/anyTestFile1 and a data/text_forms/anyTestFile2 because I was not sure if those where going to be picked up, but they did not, so it is doing what I want.... finally.