rsync 同步如何排除一个目录?

目录接口
/opt
|--build
||--bin
||--res
||--image
|--bin
|--conf
我想/opt下面所有文件(排除/opt/bin这个目录)上传到远程服务器
rsync-avzP--progress--delete-r--exclude='bin/'/opt/192.168.0.100:/opt
这样build文件夹下的bin目录也会排除掉,如何只排除/opt/bin呢?
米琪卡哇伊
浏览 300回答 2
2回答

心有法竹

rsync-avzP--progress--delete-r--exclude='/bin/'--exclude='./uploads/'/opt/192.168.0.100:/optifthepatternstartswitha/thenitisanchoredtoaparticularspotinthehierarchyoffiles,otherwiseitismatchedagainsttheendofthepathname.Thisissimilartoaleading^inregularexpressions.Thus"/foo"wouldmatchanameof"foo"ateitherthe"rootofthetransfer"(foraglobalrule)orinthemerge-file’sdirectory(foraper-directoryrule).Anunquali‐fied"foo"wouldmatchanameof"foo"anywhereinthetreebecausethealgorithmisappliedrecursivelyfromthetopdown;itbehavesasifeachpathcomponentgetsaturnatbeingtheendofthefilename.Eventheunanchored"sub/foo"wouldmatchatanypointinthehierarchywherea"foo"wasfoundwithinadirectorynamed"sub".SeethesectiononANCHORINGINCLUDE/EXCLUDEPATTERNSforafulldiscussionofhowtospecifyapatternthatmatchesattherootofthetransfer.

子衿沉夜

--exclude='./bin/'啊,建议单独写一个exclude.list,把需要排除的文件和目录写在里面,一行一条,可以使用通配符,也可以写具体匹配的路径。rsync-avzP--delete--exclude-from=exclude.list
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript