{"id":791,"date":"2025-07-27T10:00:24","date_gmt":"2025-07-27T02:00:24","guid":{"rendered":"https:\/\/www.vcidc.net\/blog\/?p=791"},"modified":"2025-07-27T10:00:24","modified_gmt":"2025-07-27T02:00:24","slug":"%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5%ef%bc%9a%e5%93%aa%e9%87%8c%e8%83%bd%e5%ae%9e%e7%8e%b0%e6%96%87%e4%bb%b6%e7%9a%84%e5%8d%b3%e6%97%b6%e6%9b%b4%e6%96%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.vcidc.net\/blog\/791.html","title":{"rendered":"\u5b9e\u65f6\u540c\u6b65\uff1a\u54ea\u91cc\u80fd\u5b9e\u73b0\u6587\u4ef6\u7684\u5373\u65f6\u66f4\u65b0\uff1f"},"content":{"rendered":"<p><h2>\u5b9e\u65f6\u540c\u6b65\u6280\u672f\u7b80\u4ecb<\/h2>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.vcidc.net\/blog\/wp-content\/uploads\/2025\/07\/5TI64k.jpg\" alt=\"\u5b9e\u65f6\u540c\u6b65\uff1a\u54ea\u91cc\u80fd\u5b9e\u73b0\u6587\u4ef6\u7684\u5373\u65f6\u66f4\u65b0\uff1f\" title=\"\u5b9e\u65f6\u540c\u6b65\uff1a\u54ea\u91cc\u80fd\u5b9e\u73b0\u6587\u4ef6\u7684\u5373\u65f6\u66f4\u65b0\uff1f\"><\/p>\n<p>\u5b9e\u65f6\u540c\u6b65\u6280\u672f\u662f\u4e00\u79cd\u901a\u8fc7\u7f51\u7edc\u5c06\u6570\u636e\u6216\u72b6\u6001\u5728\u591a\u4e2a\u8bbe\u5907\u6216\u7cfb\u7edf\u4e4b\u95f4\u5373\u65f6\u66f4\u65b0\u7684\u6280\u672f\u3002\u5b83\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u5e93\u3001\u6587\u4ef6\u5171\u4eab\u3001\u5b9e\u65f6\u901a\u4fe1\u7b49\u9886\u57df\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u73af\u5883\u4e0b\u4f7f\u7528rsync\u547d\u4ee4\u5b9e\u73b0\u6587\u4ef6\u7684\u5b9e\u65f6\u540c\u6b65\uff0c\u5e76\u63d0\u4f9b\u64cd\u4f5c\u6b65\u9aa4\u3001\u547d\u4ee4\u793a\u4f8b\u53ca\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<p><h2>\u5b9e\u65f6\u540c\u6b65\u4efb\u52a1\u6982\u8ff0<\/h2>\n<\/p>\n<p>\u672c\u6587\u7684\u4efb\u52a1\u662f\u5b9e\u73b0\u4e24\u4e2aLinux\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u6587\u4ef6\u5b9e\u65f6\u540c\u6b65\uff0c\u786e\u4fdd\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6\u66f4\u6539\u80fd\u591f\u5373\u65f6\u53cd\u6620\u5230\u53e6\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n<p><h2>\u64cd\u4f5c\u6b65\u9aa4<\/h2>\n<\/p>\n<p><h3>\u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5rsync<\/h3>\n<\/p>\n<p>\u5728\u4e24\u4e2a\u670d\u52a1\u5668\u4e0a\u5b89\u88c5rsync\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u6210\u5b89\u88c5\uff1a<\/p>\n<p><pre><code>sudo apt-get update<\/p>\r\n<p>sudo apt-get install rsync<\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6e\u540c\u6b65\u89c4\u5219<\/h3>\n<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u540c\u6b65\u89c4\u5219\u6587\u4ef6\uff0c\u4f8b\u5982`sync_rules.txt`\uff0c\u7528\u4e8e\u5b9a\u4e49\u540c\u6b65\u7684\u76ee\u5f55\u548c\u6392\u9664\u7684\u6587\u4ef6\u3002<\/p>\n<p><pre><code>\/path\/to\/source_directory\/ \/path\/to\/destination_directory\/<\/p>\r\n<p>--exclude='.tmp'<\/p>\r\n<p>--exclude='.log'<\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4\u4e09\uff1a\u521b\u5efa\u540c\u6b65\u811a\u672c<\/h3>\n<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u540c\u6b65\u811a\u672c\uff0c\u4f8b\u5982`sync_script.sh`\uff0c\u7528\u4e8e\u5b9a\u65f6\u6267\u884c\u540c\u6b65\u4efb\u52a1\u3002<\/p>\n<p><pre><code>!\/bin\/bash<\/p>\r\n<p>RSYNC_PATH=\"\/usr\/bin\/rsync\"<\/p>\r\n<p>RSYNC_RULES=\"sync_rules.txt\"<\/p>\r\n<p>SOURCE_DIR=\"\/path\/to\/source_directory\"<\/p>\r\n<p>DEST_DIR=\"\/path\/to\/destination_directory\"<\/p>\r\n\r\n<p>$RSYNC_PATH --quiet --delete --exclude-from=$RSYNC_RULES $SOURCE_DIR $DEST_DIR<\/code><\/pre>\n<\/p>\n<p>\u5c06\u811a\u672c\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a<\/p>\n<p><pre><code>chmod +x sync_script.sh<\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4\u56db\uff1a\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<\/p>\n<p>\u4f7f\u7528crontab\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\uff0c\u4f7f\u540c\u6b65\u811a\u672c\u6bcf\u9694\u4e00\u5b9a\u65f6\u95f4\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p><pre><code>crontab -e<\/code><\/pre>\n<\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u5047\u8bbe\u6bcf5\u5206\u949f\u540c\u6b65\u4e00\u6b21\uff1a<\/p>\n<p><pre><code>\/5     \/path\/to\/sync_script.sh<\/code><\/pre>\n<\/p>\n<p><h2>\u547d\u4ee4\u793a\u4f8b\u53ca\u89e3\u91ca<\/h2>\n<\/p>\n<p><h3>\u547d\u4ee4\u793a\u4f8b<\/h3>\n<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528rsync\u547d\u4ee4\u540c\u6b65\u6587\u4ef6\u7684\u793a\u4f8b\uff1a<\/p>\n<p><pre><code>rsync --quiet --delete --exclude-from=sync_rules.txt \/path\/to\/source_directory\/ \/path\/to\/destination_directory\/<\/code><\/pre>\n<\/p>\n<p><h3>\u547d\u4ee4\u89e3\u91ca<\/h3>\n<\/p>\n<ul>\n<li><strong>rsync<\/strong>\uff1a\u6267\u884c\u540c\u6b65\u64cd\u4f5c\u7684\u547d\u4ee4\u3002<\/li>\n<li><strong>&#8211;quiet<\/strong>\uff1a\u51cf\u5c11\u8f93\u51fa\u4fe1\u606f\uff0c\u4ec5\u663e\u793a\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n<li><strong>&#8211;delete<\/strong>\uff1a\u5220\u9664\u76ee\u6807\u76ee\u5f55\u4e2d\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\u3002<\/li>\n<li><strong>&#8211;exclude-from<\/strong>\uff1a\u6307\u5b9a\u6392\u9664\u89c4\u5219\u6587\u4ef6\u3002<\/li>\n<li><strong>\/path\/to\/source_directory\/<\/strong>\uff1a\u6e90\u76ee\u5f55\u8def\u5f84\u3002<\/li>\n<li><strong>\/path\/to\/destination_directory\/<\/strong>\uff1a\u76ee\u6807\u76ee\u5f55\u8def\u5f84\u3002<\/li>\n<\/ul>\n<p><h2>\u6ce8\u610f\u4e8b\u9879<\/h2>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u4e24\u4e2a\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u7f51\u7edc\u8fde\u63a5\u7a33\u5b9a\u3002<\/li>\n<li>\u540c\u6b65\u89c4\u5219\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\u5e94\u6b63\u786e\u65e0\u8bef\u3002<\/li>\n<li>\u5b9a\u65f6\u4efb\u52a1\u8bbe\u7f6e\u5408\u7406\uff0c\u907f\u514d\u8fc7\u4e8e\u9891\u7e41\u6216\u8fc7\u4e8e\u7a00\u758f\u7684\u540c\u6b65\u3002<\/li>\n<\/ul>\n<p><h2>\u5b9e\u7528\u6280\u5de7<\/h2>\n<\/p>\n<ul>\n<li>\u4f7f\u7528SSH\u5bc6\u94a5\u8ba4\u8bc1\uff0c\u63d0\u9ad8\u540c\u6b65\u5b89\u5168\u6027\u3002<\/li>\n<li>\u5728\u540c\u6b65\u89c4\u5219\u4e2d\u6392\u9664\u654f\u611f\u6587\u4ef6\uff0c\u5982\u5bc6\u7801\u6587\u4ef6\u7b49\u3002<\/li>\n<li>\u76d1\u63a7\u540c\u6b65\u8fc7\u7a0b\uff0c\u786e\u4fdd\u540c\u6b65\u4efb\u52a1\u6b63\u5e38\u8fd0\u884c\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u65f6\u540c\u6b65\u6280\u672f\u7b80\u4ecb \u5b9e\u65f6\u540c\u6b65\u6280\u672f\u662f\u4e00\u79cd\u901a\u8fc7\u7f51\u7edc\u5c06\u6570\u636e\u6216\u72b6\u6001\u5728\u591a\u4e2a\u8bbe\u5907\u6216\u7cfb\u7edf\u4e4b\u95f4\u5373\u65f6\u66f4\u65b0\u7684\u6280\u672f\u3002\u5b83\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u5e93\u3001\u6587\u4ef6\u5171\u4eab\u3001\u5b9e\u65f6\u901a\u4fe1\u7b49\u9886\u57df\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u73af\u5883\u4e0b\u4f7f\u7528rsync\u547d\u4ee4\u5b9e\u73b0\u6587\u4ef6\u7684\u5b9e\u65f6\u540c\u6b65\uff0c\u5e76\u63d0\u4f9b\u64cd\u4f5c\u6b65\u9aa4\u3001\u547d\u4ee4\u793a\u4f8b\u53ca\u6ce8&#8230;<\/p>\n","protected":false},"author":1,"featured_media":792,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[322,320,321],"topic":[],"class_list":["post-791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hk-server","tag-rsync","tag-320","tag-321"],"_links":{"self":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/comments?post=791"}],"version-history":[{"count":1,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/791\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/791\/revisions\/794"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media\/792"}],"wp:attachment":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media?parent=791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/categories?post=791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/tags?post=791"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/topic?post=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}