woo robbin
2006-Nov-01 05:00 UTC
How to rsync only specified subdirectories in the source folder?
Hi all, For example,if there is ten subdirectories named sub1~sub10(each including subdirectories and files too),and file1~file10,how can I rsync only sub2 and sub 3 to the target? /---- MyFolder |---------- sub1 |---------- sub2 |---------- sub3 |---------- sub4 |---------- sub5 |---------- sub6 |---------- sub7 |---------- sub8 |---------- sub9 |---------- sub10 |---------- file1 |---------- file2 |---------- file3 |---------- file4 |---------- file5 |---------------------- rsync -av --delete --include "/sub2/" --include "/sub3/" /MyFolder/ /dest/ this seems to sync other directories and files too. -------------- next part -------------- HTML attachment scrubbed and removed
Wesley W. Terpstra
2006-Nov-01 13:14 UTC
How to rsync only specified subdirectories in the source folder?
On Nov 1, 2006, at 6:00 AM, woo robbin wrote:> For example,if there is ten subdirectories named sub1~sub10(each > including subdirectories and files too),and file1~file10,how can I > rsync only sub2 and sub 3 to the target? > > rsync -av --delete --include "/sub2/" --include "/sub3/" / > MyFolder/ /dest/ > this seems to sync other directories and files too.The reason that doesn't work is because include only cancels out an exclude. Since you've not excluded anything, the include does nothing. You could add an --exclude '/*' if you wanted to do this with include/excludes: rsync -av --delete --include "/sub2/" --include "/sub3/"--exclude '/ *' /MyFolder/ /dest/ However, rsync -av --delete /MyFolder/sub2 /MyFolder/sub3 /dest is probably the simplest (and therefore best) solution.