\u5bf9\u4e8e\u590d\u5236\u76ee\u5f55\uff0c\u5c31\u6709\u4e86\u5f88\u5927\u7684\u5206\u6b67\uff0c\u8fd9\u4e5f\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48 rsync \u4f1a\u88ab\u8ba4\u4e3a\u6bd4 scp \u66f4\u590d\u6742\u3002\u5982\u679c\u4f60\u60f3\u628a bar \u76ee\u5f55\u590d\u5236\u5230 server \u670d\u52a1\u5668\u4e0a\uff0c\u9664\u4e86\u6307\u5b9a ssh \u4fe1\u606f\u5916\uff0c\u76f8\u5e94\u7684 scp \u547d\u4ee4\u548c cp \u547d\u4ee4\u4e00\u6a21\u4e00\u6837\u3002<\/p>\n
\r\n$ scp -r bar\/ me@server:\/home\/me\/\r\n<\/pre>\n\u5bf9\u4e8e rsync\uff0c\u8003\u8651\u7684\u56e0\u7d20\u6bd4\u8f83\u591a\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u6bd4\u8f83\u5f3a\u5927\u7684\u5de5\u5177\u3002\u9996\u5148\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u6700\u7b80\u5355\u7684\u5f62\u5f0f\uff1a<\/p>\n
\r\n$ rsync -r bar\/ me@server:\/home\/me\/\r\n<\/pre>\n\u770b\u8d77\u6765\u5f88\u7b80\u5355\u5427\uff1f\u5bf9\u4e8e\u53ea\u5305\u542b\u76ee\u5f55\u548c\u666e\u901a\u6587\u4ef6\u7684\u7b80\u5355\u60c5\u51b5\uff0c\u8fd9\u5c31\u53ef\u4ee5\u4e86\u3002\u7136\u800c\uff0crsync \u66f4\u5728\u610f\u53d1\u9001\u4e0e\u4e3b\u673a\u7cfb\u7edf\u4e2d\u4e00\u6a21\u4e00\u6837\u7684\u6587\u4ef6\u3002\u8ba9\u6211\u4eec\u6765\u521b\u5efa\u4e00\u4e2a\u7a0d\u5fae\u590d\u6742\u4e00\u4e9b\uff0c\u4f46\u5e76\u4e0d\u7f55\u89c1\u7684\u4f8b\u5b50\uff1a<\/p>\n
\r\n# \u521b\u5efa\u591a\u7ea7\u76ee\u5f55\u7ed3\u6784\r\n$ mkdir -p bar\/baz\r\n# \u5728\u5176\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u6587\u4ef6\r\n$ touch bar\/foo.txt\r\n# \u73b0\u5728\u521b\u5efa\u4e00\u4e2a\u7b26\u53f7\u94fe\u63a5\u6307\u56de\u5230\u8be5\u6587\u4ef6\r\n$ cd bar\/baz\r\n$ ln -s ..\/foo.txt link.txt\r\n# \u8fd4\u56de\u539f\u4f4d\u7f6e\r\n$ cd -\r\n<\/pre>\n\u73b0\u5728\u6211\u4eec\u6709\u4e86\u4e00\u4e2a\u5982\u4e0b\u7684\u76ee\u5f55\u6811\uff1a<\/p>\n
\r\nbar\r\n\u251c\u2500\u2500 baz\r\n\u2502 \u2514\u2500\u2500 link.txt -> ..\/foo.txt\r\n\u2514\u2500\u2500 foo.txt\r\n \r\n1 directory, 2 files\r\n<\/pre>\n\u5982\u679c\u6211\u4eec\u5c1d\u8bd5\u4e0a\u9762\u7684\u547d\u4ee4\u6765\u590d\u5236 bar\uff0c\u6211\u4eec\u4f1a\u6ce8\u610f\u5230\u975e\u5e38\u4e0d\u540c\u7684\uff08\u5e76\u4ee4\u4eba\u60ca\u8bb6\u7684\uff09\u7ed3\u679c\u3002\u9996\u5148\uff0c\u6211\u4eec\u6765\u8bd5\u8bd5 scp\uff1a<\/p>\n
\r\n$ scp -r bar\/ me@server:\/home\/me\/\r\n<\/pre>\n\u5982\u679c\u4f60 ssh \u8fdb\u5165\u4f60\u7684\u670d\u52a1\u5668\uff0c\u770b\u770b bar \u7684\u76ee\u5f55\u6811\uff0c\u4f60\u4f1a\u53d1\u73b0\u5b83\u548c\u4f60\u7684\u4e3b\u673a\u7cfb\u7edf\u6709\u4e00\u4e2a\u91cd\u8981\u800c\u5fae\u5999\u7684\u533a\u522b\uff1a<\/p>\n
\r\nbar\r\n\u251c\u2500\u2500 baz\r\n\u2502 \u2514\u2500\u2500 link.txt\r\n\u2514\u2500\u2500 foo.txt\r\n \r\n1 directory, 2 files\r\n<\/pre>\n\u8bf7\u6ce8\u610f\uff0clink.txt \u4e0d\u518d\u662f\u4e00\u4e2a\u7b26\u53f7\u94fe\u63a5\uff0c\u5b83\u73b0\u5728\u662f\u4e00\u4e2a foo.txt \u7684\u5b8c\u6574\u526f\u672c\u3002\u5982\u679c\u4f60\u4e60\u60ef\u4e8e\u4f7f\u7528 cp\uff0c\u8fd9\u53ef\u80fd\u4f1a\u662f\u4ee4\u4eba\u60ca\u8bb6\u7684\u884c\u4e3a\u3002\u5982\u679c\u4f60\u5c1d\u8bd5\u4f7f\u7528 cp -r \u590d\u5236 bar \u76ee\u5f55\uff0c\u4f60\u4f1a\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\uff0c\u91cc\u9762\u7684\u7b26\u53f7\u94fe\u63a5\u548c bar \u7684\u4e00\u6837\u3002\u73b0\u5728\u5982\u679c\u6211\u4eec\u5c1d\u8bd5\u4f7f\u7528\u4e4b\u524d\u7684 rsync \u547d\u4ee4\uff0c\u6211\u4eec\u4f1a\u5f97\u5230\u4e00\u4e2a\u8b66\u544a\uff1a<\/p>\n
\r\n$ rsync -r bar\/ me@server:\/home\/me\/\r\nskipping non-regular file \"bar\/baz\/link.txt\"\r\n<\/pre>\nrsync \u8b66\u544a\u6211\u4eec\u5b83\u53d1\u73b0\u4e86\u4e00\u4e2a\u975e\u5e38\u89c4\u6587\u4ef6\uff0c\u5e76\u6b63\u5728\u8df3\u8fc7\u5b83\u3002\u56e0\u4e3a\u4f60\u6ca1\u6709\u544a\u8bc9\u5b83\u53ef\u4ee5\u590d\u5236\u7b26\u53f7\u94fe\u63a5\uff0c\u6240\u4ee5\u5b83\u5ffd\u7565\u4e86\u5b83\u4eec\u3002rsync \u5728\u624b\u518c\u4e2d\u6709\u4e00\u8282\u201c\u7b26\u53f7\u94fe\u63a5\u201d\uff0c\u89e3\u91ca\u4e86\u6240\u6709\u53ef\u80fd\u7684\u884c\u4e3a\u9009\u9879\u3002\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u6dfb\u52a0 -links \u6807\u5fd7\uff1a<\/p>\n
\r\n$ rsync -r --links bar\/ me@server:\/home\/me\/\r\n<\/pre>\n\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\uff0c\u6211\u4eec\u770b\u5230\u8fd9\u4e2a\u7b26\u53f7\u94fe\u63a5\u662f\u4f5c\u4e3a\u4e00\u4e2a\u7b26\u53f7\u94fe\u63a5\u590d\u5236\u8fc7\u6765\u7684\u3002\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e0e scp \u590d\u5236\u7b26\u53f7\u94fe\u63a5\u7684\u65b9\u5f0f\u4e0d\u540c\u3002<\/p>\n
\r\nbar\/\r\n\u251c\u2500\u2500 baz\r\n\u2502 \u2514\u2500\u2500 link.txt -> ..\/foo.txt\r\n\u2514\u2500\u2500 foo.txt\r\n \r\n1 directory, 2 files\r\n<\/pre>\n\u4e3a\u4e86\u7701\u53bb\u4e00\u4e9b\u6253\u5b57\u5de5\u4f5c\uff0c\u5e76\u5229\u7528\u66f4\u591a\u7684\u6587\u4ef6\u4fdd\u62a4\u9009\u9879\uff0c\u5728\u590d\u5236\u76ee\u5f55\u65f6\u53ef\u4ee5\u4f7f\u7528\u5f52\u6863\u6807\u5fd7 -archive\uff08\u7b80\u79f0 -a\uff09\u3002\u8be5\u5f52\u6863\u6807\u5fd7\u5c06\u505a\u5927\u591a\u6570\u4eba\u6240\u671f\u671b\u7684\u4e8b\u60c5\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5b9e\u73b0\u9012\u5f52\u590d\u5236\u3001\u7b26\u53f7\u94fe\u63a5\u590d\u5236\u548c\u8bb8\u591a\u5176\u4ed6\u9009\u9879\u3002<\/p>\n
\r\n$ rsync -a bar\/ me@server:\/home\/me\/\r\n<\/pre>\n\u5982\u679c\u4f60\u611f\u5174\u8da3\u7684\u8bdd\uff0crsync \u624b\u518c\u9875\u6709\u5173\u4e8e\u5b58\u6863\u6807\u5fd7\u7684\u6df1\u5165\u89e3\u91ca\u3002<\/p>\n
\u6ce8\u610f\u4e8b\u9879<\/strong><\/div>\n\u4e0d\u8fc7\uff0c\u4f7f\u7528 rsync \u6709\u4e00\u4e2a\u6ce8\u610f\u4e8b\u9879\u3002\u4f7f\u7528 scp \u6bd4\u4f7f\u7528 rsync \u66f4\u5bb9\u6613\u6307\u5b9a\u4e00\u4e2a\u975e\u6807\u51c6\u7684 ssh \u7aef\u53e3\u3002\u4f8b\u5982\uff0c\u5982\u679c server \u4f7f\u7528 8022 \u7aef\u53e3\u7684 SSH \u8fde\u63a5\uff0c\u90a3\u4e48\u8fd9\u4e9b\u547d\u4ee4\u5c31\u4f1a\u50cf\u8fd9\u6837\uff1a<\/p>\n
\r\n$ scp -P 8022 foo.txt me@server:\/home\/me\/\r\n<\/pre>\n\u800c\u5728\u4f7f\u7528 rsync \u65f6\uff0c\u4f60\u5fc5\u987b\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u201c\u8fdc\u7a0b shell\u201d\u547d\u4ee4\uff0c\u9ed8\u8ba4\u662f ssh\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 -e \u6807\u5fd7\u6765\u6307\u5b9a\u3002<\/p>\n
\r\n$ rsync -e 'ssh -p 8022' foo.txt me@server:\/home\/me\/\r\n<\/pre>\nrsync \u4f1a\u4f7f\u7528\u4f60\u7684 ssh \u914d\u7f6e\uff1b\u4f46\u662f\uff0c\u5982\u679c\u4f60\u7ecf\u5e38\u8fde\u63a5\u5230\u8fd9\u4e2a\u670d\u52a1\u5668\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7684 ~\/.ssh\/config \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u3002\u8fd9\u6837\u4f60\u5c31\u4e0d\u9700\u8981\u518d\u4e3a rsync \u6216 ssh \u547d\u4ee4\u6307\u5b9a\u7aef\u53e3\u4e86\uff01<\/p>\n
\r\nHost server\r\n Port 8022\r\n<\/pre>\n\u53e6\u5916\uff0c\u5982\u679c\u4f60\u8fde\u63a5\u7684\u6bcf\u4e00\u53f0\u670d\u52a1\u5668\u90fd\u5728\u540c\u4e00\u4e2a\u975e\u6807\u51c6\u7aef\u53e3\u4e0a\u8fd0\u884c\uff0c\u4f60\u8fd8\u53ef\u4ee5\u914d\u7f6e RSYNC_RSH \u73af\u5883\u53d8\u91cf\u3002<\/p>\n
\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u4ecb\u7ecd\u4e86\u4ece scp \u5207\u6362\u5230 rsync \u7684\u65e5\u5e38\u4f7f\u7528\u6848\u4f8b\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u8ba9\u6211\u4eec\u82b1\u4e00\u4e9b\u65f6\u95f4\u6765\u63a2\u8ba8\u4e00\u4e0b\u4e3a\u4ec0\u4e48\u4f60\u53ef\u80fd\u60f3\u8981\u4f7f\u7528 rsync \u7684\u4f18\u70b9\u3002\u5f88\u591a\u4eba\u5728\u5f88\u4e45\u4ee5\u524d\u5c31\u5df2\u7ecf\u5f00\u59cb\u4f7f\u7528 rsync \u4e86\uff0c\u5c31\u662f\u56e0\u4e3a\u8fd9\u4e9b\u4f18\u70b9\u3002<\/p>\n
\u5373\u65f6\u538b\u7f29<\/strong><\/div>\n\u5982\u679c\u4f60\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u7f51\u7edc\u8fde\u63a5\u901f\u5ea6\u8f83\u6162\u6216\u6709\u9650\uff0crsync \u53ef\u4ee5\u82b1\u8d39\u66f4\u591a\u7684 CPU \u5904\u7406\u80fd\u529b\u6765\u8282\u7701\u7f51\u7edc\u5e26\u5bbd\u3002\u5b83\u901a\u8fc7\u5728\u53d1\u9001\u6570\u636e\u4e4b\u524d\u5bf9\u6570\u636e\u8fdb\u884c\u5373\u65f6\u538b\u7f29\u6765\u5b9e\u73b0\u3002\u538b\u7f29\u53ef\u4ee5\u7528 -z \u6807\u5fd7\u6765\u542f\u7528\u3002<\/p>\n
\u5dee\u91cf\u4f20\u8f93<\/strong><\/div>\nrsync \u4e5f\u53ea\u5728\u76ee\u6807\u6587\u4ef6\u4e0e\u6e90\u6587\u4ef6\u4e0d\u540c\u7684\u60c5\u51b5\u4e0b\u590d\u5236\u6587\u4ef6\u3002\u8fd9\u53ef\u4ee5\u5728\u76ee\u5f55\u4e2d\u9012\u5f52\u5730\u5de5\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u62ff\u6211\u4eec\u4e0a\u9762\u7684\u6700\u540e\u4e00\u4e2a bar \u7684\u4f8b\u5b50\uff0c\u5e76\u591a\u6b21\u91cd\u65b0\u8fd0\u884c\u90a3\u4e2a rsync \u547d\u4ee4\uff0c\u90a3\u4e48\u5728\u6700\u521d\u7684\u4f20\u8f93\u4e4b\u540e\u5c31\u4e0d\u4f1a\u6709\u4efb\u4f55\u4f20\u8f93\u3002\u5982\u679c\u4f60\u77e5\u9053\u4f60\u4f1a\u91cd\u590d\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u4f8b\u5982\u5907\u4efd\u5230 U \u76d8\uff0c\u90a3\u4e48\u4f7f\u7528 rsync \u5373\u4f7f\u662f\u8fdb\u884c\u672c\u5730\u590d\u5236\u4e5f\u662f\u503c\u5f97\u7684\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u529f\u80fd\u53ef\u4ee5\u8282\u7701\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u7684\u5927\u91cf\u7684\u65f6\u95f4\u3002<\/p>\n
\u540c\u6b65<\/strong><\/div>\n\u987e\u540d\u601d\u4e49\uff0crsync \u53ef\u4ee5\u505a\u7684\u4e0d\u4ec5\u4ec5\u662f\u590d\u5236\u6570\u636e\u3002\u5230\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u4eec\u53ea\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 rsync \u590d\u5236\u6587\u4ef6\u3002\u5982\u679c\u4f60\u60f3\u8ba9 rsync \u628a\u76ee\u6807\u76ee\u5f55\u53d8\u6210\u6e90\u76ee\u5f55\u7684\u6837\u5b50\uff0c\u4f60\u53ef\u4ee5\u5728 rsync \u4e2d\u6dfb\u52a0\u5220\u9664\u6807\u5fd7 -delete\u3002\u8fd9\u4e2a\u5220\u9664\u6807\u5fd7\u4f7f\u5f97 rsync \u5c06\u4ece\u6e90\u76ee\u5f55\u4e2d\u590d\u5236\u4e0d\u5b58\u5728\u4e8e\u76ee\u6807\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\uff0c\u7136\u540e\u5b83\u5c06\u5220\u9664\u76ee\u6807\u76ee\u5f55\u4e2d\u4e0d\u5b58\u5728\u4e8e\u6e90\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002\u7ed3\u679c\u5c31\u662f\u76ee\u6807\u76ee\u5f55\u548c\u6e90\u76ee\u5f55\u5b8c\u5168\u4e00\u6837\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0cscp \u53ea\u4f1a\u5728\u76ee\u6807\u76ee\u5f55\u4e0b\u6dfb\u52a0\u6587\u4ef6\u3002<\/p>\n
\u7ed3\u8bba<\/strong><\/div>\n\u5bf9\u4e8e\u7b80\u5355\u7684\u4f7f\u7528\u60c5\u51b5\uff0crsync \u5e76\u4e0d\u6bd4\u8001\u724c\u7684 scp \u5de5\u5177\u590d\u6742\u591a\u5c11\u3002\u552f\u4e00\u663e\u8457\u7684\u533a\u522b\u662f\u5728\u9012\u5f52\u590d\u5236\u76ee\u5f55\u65f6\u4f7f\u7528 -a \u800c\u4e0d\u662f -r\u3002\u7136\u800c\uff0c\u6b63\u5982\u6211\u4eec\u770b\u5230\u7684\uff0crsync \u7684 -a \u6807\u5fd7\u6bd4 scp \u7684 -r \u6807\u5fd7\u66f4\u50cf cp \u7684 -r \u6807\u5fd7\u3002<\/p>\n
\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u65b0\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u52a0\u5feb\u4f60\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u7136\u800c\uff0c\u5f88\u591a\u7528\u6237\u90fd\u662f\u4ece\u5c0f\u7528\u7740 scp \u547d\u4ee4\u957f\u5927\u7684\uff0c\u6240\u4ee5\u5bf9 rsync \u5e76\u4e0d\u719f\u6089\u3002\u6b64\u5916\uff0crsync \u53ef\u4ee5\u505a\u7684\u4e8b\u60c5\u4e5f […]<\/p>\n","protected":false},"author":1329,"featured_media":200268,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-200262","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=200262"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200262\/revisions"}],"predecessor-version":[{"id":200270,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200262\/revisions\/200270"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/200268"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=200262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=200262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=200262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}