{"id":168341,"date":"2020-01-08T09:06:33","date_gmt":"2020-01-08T01:06:33","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=168341"},"modified":"2019-12-30T11:09:05","modified_gmt":"2019-12-30T03:09:05","slug":"rsync-file-use","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/rsync-file-use.html","title":{"rendered":"\u5982\u4f55\u7528Rsync\u5b9e\u73b0\u6587\u4ef6\u7684\u540c\u6b65"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nsync\u548cscp\u5728\u6587\u4ef6\u5939\u5747\u4e0d\u5b58\u5728\u65f6\uff0c\u6267\u884c\u65f6\u95f4\u76f8\u5dee\u4e0d\u5927\uff0c\u4f46\u662f\u6587\u4ef6\u5939\u5b58\u5728\u7684\u60c5\u51b5\u4e0b\u5dee\u5f02\u5f88\u5927\u3002\u539f\u56e0\u662fscp\u662f\u590d\u5236\uff1a\u82e5mas2\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u65b0\u5efa\uff0c\u82e5\u5b58\u5728\u5219\u8986\u76d6\uff0c\u82e5mas2\u4e0a\u6709\u800cDashboard\u4e3b\u673a\u6ca1\u6709\uff0c\u5219\u4e0d\u6539\u53d8\u3002\u53ef\u4ee5\u7406\u89e3\u4e3ascp\u4e3a\u201c\u590d\u5236\u201d\u3002\u800crsync\u5219\u5728\u6587\u4ef6\u5728\u5b58\u5728\u4e8e\u4e24\u4e3b\u673a\u65f6\uff0c\u6bd4\u8f83\u4e24\u6587\u4ef6\u662f\u591f\u76f8\u540c\uff0c\u76f8\u540c\u7684\u8bdd\uff0c\u5c31\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u82e5\u5b58\u5728\u5dee\u5f02\u5c31\u76f4\u63a5\u66f4\u65b0\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6545\u4e8b\u80cc\u666f\uff1a\u6211\u4eec\u516c\u53f8\u662f\u505a\u65b0\u96f6\u552e\u7684\uff0c\u9700\u8981\u5bf9\u53d1\u5e03\u7684\u6bcf\u53f0\u673a\u5668\u8fdb\u884c\u6587\u4ef6\u7684\u540c\u6b65\u66f4\u65b0\uff0c\u6240\u4ee5\u6211\u8fd9\u91cc\u505a\u4e86\u4e00\u4e2a\u5c0f\u5c0f\u7684\u8c03\u7814<\/p>\n

\u6280\u672f\u8c03\u7814\uff1aLinux\u4e4b\u95f4\u540c\u6b65\u6587\u4ef6\u6709\u4e24\u79cd\u65b9\u5f0frsync\u4e0escp\u3002<\/p>\n

sync\u548cscp\u5728\u6587\u4ef6\u5939\u5747\u4e0d\u5b58\u5728\u65f6\uff0c\u6267\u884c\u65f6\u95f4\u76f8\u5dee\u4e0d\u5927\uff0c\u4f46\u662f\u6587\u4ef6\u5939\u5b58\u5728\u7684\u60c5\u51b5\u4e0b\u5dee\u5f02\u5f88\u5927\u3002\u539f\u56e0\u662fscp\u662f\u590d\u5236\uff1a\u82e5mas2\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u65b0\u5efa\uff0c\u82e5\u5b58\u5728\u5219\u8986\u76d6\uff0c\u82e5mas2\u4e0a\u6709\u800cDashboard\u4e3b\u673a\u6ca1\u6709\uff0c\u5219\u4e0d\u6539\u53d8\u3002\u53ef\u4ee5\u7406\u89e3\u4e3ascp\u4e3a\u201c\u590d\u5236\u201d\u3002\u800crsync\u5219\u5728\u6587\u4ef6\u5728\u5b58\u5728\u4e8e\u4e24\u4e3b\u673a\u65f6\uff0c\u6bd4\u8f83\u4e24\u6587\u4ef6\u662f\u591f\u76f8\u540c\uff0c\u76f8\u540c\u7684\u8bdd\uff0c\u5c31\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u82e5\u5b58\u5728\u5dee\u5f02\u5c31\u76f4\u63a5\u66f4\u65b0\u3002<\/p>\n

\u7b80\u5355\u7684\u8bf4rsync\u53ea\u5bf9\u5dee\u5f02\u6587\u4ef6\u505a\u66f4\u65b0\u3002<\/p>\n

#### Rsync\u4ecb\u7ecd<\/strong><\/div>\n

rsync\u662f\u4e00\u6b3e\u5f00\u6e90\u7684\u5907\u4efd\u5de5\u5177\uff0c\u53ef\u4ee5\u518d\u4e0d\u540c\u4e3b\u673a\u4e4b\u95f4\u8fdb\u884c\u540c\u6b65\uff0c\u5b9e\u73b0\u5168\u91cf\u548c\u589e\u91cf\u5907\u4efd\uff0c\u9002\u7528\u4e8e\u96c6\u4e2d\u5907\u4efd\u6216\u5f02\u5730\u5907\u4efd\u7b49\u5e94\u7528\u573a\u666f\u3002
\nrsync\u76d1\u542c\u7aef\u53e3\uff1a873
\nrsync\u8fd0\u884c\u6a21\u5f0f\uff1aC\/S<\/p>\n

#### Rsync\u4f20\u8f93\u6a21\u5f0f<\/strong><\/div>\n

- \u672c\u5730\u6a21\u5f0f
\n\u672c\u5730\u4f20\u8f93\uff0c\u4e3b\u673a\u5185\u90e8\u8fdb\u884c\u6570\u636e\u4f20\u8f93\uff08\u7c7b\u4f3c\u4e8ecp\u547d\u4ee4\uff09
\n- \u8fdc\u7a0b\u6a21\u5f0f
\n\u8fdc\u7a0b\u901a\u9053\u4f20\u8f93\uff0c\u901a\u8fc7ssh\u901a\u9053\u4f20\u8f93\u6570\u636e\uff08\u7c7b\u4f3cscp\u547d\u4ee4\uff09
\n- \u5b88\u62a4\u8fdb\u7a0b\u6a21\u5f0f
\n\u5b88\u62a4\u8fdb\u7a0b\u4f20\u8f93\uff0c\u4e0d\u4f7f\u7528\u7cfb\u7edf\u7528\u6237\u8fdb\u884c\u4f20\u8f93\uff08\u5b89\u5168\u6027\u9ad8\uff09<\/p>\n

#### Rsync\u547d\u4ee4\u53c2\u6570<\/strong><\/div>\n

-a \u590d\u5236\u5404\u79cd\u7c7b\u578b\u7684\u6587\u4ef6\uff08\u76f8\u5f53\u4e8e-tropgDl\uff09
\n-v \u663e\u793a\u4f20\u8f93\u8fc7\u7a0b
\n-z \u4f20\u8f93\u65f6\u8fdb\u884c\u538b\u7f29
\n-r \u9012\u5f52\u4f20\u8f93\u76ee\u5f55\u548c\u5b50\u76ee\u5f55
\n-t \u4fdd\u6301\u6587\u4ef6\u65f6\u95f4\u4e0d\u53d8
\n-o \u4fdd\u6301\u6587\u4ef6\u5c5e\u4e3b\u4fe1\u606f
\n-g \u4fdd\u6301\u6587\u4ef6\u5c5e\u7ec4\u4fe1\u606f
\n-p \u4fdd\u6301\u6587\u4ef6\u6743\u9650
\n-l \u4fdd\u6301\u8f6f\u8fde\u63a5
\n-P \u663e\u793a\u540c\u6b65\u8fdb\u5ea6\u53ca\u8fc7\u7a0b
\n-D \u4fdd\u6301\u8bbe\u5907\u6587\u4ef6\u4fe1\u606f
\n--bwlimit=100 \u9650\u901f\u4f20\u8f93
\n--delete \u6e90\u548c\u76ee\u6807\u6570\u636e\u4fdd\u6301\u4e00\u81f4
\n--partial \u65ad\u70b9\u7eed\u4f20<\/p>\n

#### \u5b89\u88c5rsync<\/strong><\/div>\n
`sudo apt-get install`\u4e00\u822c\u673a\u5668\u597d\u50cf\u90fd\u6709\r\n<\/pre>\n
#### \u670d\u52a1\u7aef<\/strong><\/div>\n

1. \u521b\u5efarsyncd.conf\u914d\u7f6e\u6587\u4ef6\uff0csudo vim \/etc\/rsyncd.conf<\/p>\n

`uid = ai #\u8fd0\u884c\u8fdb\u7a0b\u7528\u6237\r\ngid = ai #\u8fd0\u884c\u7528\u6237\u7ec4\r\nport = 873 #\u76d1\u542c\u7aef\u53e3\r\nfake super = yes #\u65e0\u9700rsync\u4ee5root\u8eab\u4efd\u8fd0\u884c\uff0c\u5141\u8bb8\u63a5\u53d7\u6570\u636e\r\nuse chroot = no #\u7981\u9522\u63a8\u9001\u6570\u636e\u81f3\u67d0\u4e2a\u76ee\u5f55\r\nmax connections = 0 #\u6700\u5927\u8fde\u63a5\u6570\r\ntimeout = 600 #\u8d85\u65f6\u65f6\u95f4\r\nlog file = \/var\/log\/rsyncd.log #\u5b9a\u4e49\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\r\n#####################################\r\n[backup] #\u6a21\u5757\u540d\u79f0\r\npath = \/backup #\u5b9a\u4e49\u63a5\u6536\u5907\u4efd\u6570\u636e\u76ee\u5f55\r\nignore errors #\u5ffd\u7565\u9519\u8bef\u4fe1\u606f\r\nread only = false #\u5bf9\u5907\u4efd\u6570\u636e\u53ef\u8bfb\u5199\r\nlist = false #\u4e0d\u5141\u8bb8\u67e5\u770b\u6a21\u5757\u4fe1\u606f\r\nauth users = test #\u5b9a\u4e49\u865a\u62df\u7528\u6237\uff0c\u8ba4\u8bc1\u4f7f\u7528\r\nsecrets file = \/etc\/rsync.passwd #\u8ba4\u8bc1\u5bc6\u7801\u8def\u5f84`\r\n<\/pre>\n

2. \u521b\u5efarsync.passwd<\/p>\n

`echo \"test:123456\" > \/etc\/rsync.passwd\r\nchmod 600 \/etc\/rsync.passwd \u4e0d\u7136\u4f20\u8f93\u4f1a\u62a5\u9519`\r\n<\/pre>\n

3. \u542f\u52a8rsync<\/p>\n

`rsync --daemon`\r\n<\/pre>\n
#### \u5ba2\u6237\u7aef<\/strong><\/div>\n

1. \u521b\u5efarsync.passwd<\/p>\n

`echo \"123456\" > \/etc\/rsync.password\r\nchmod 600 \/etc\/rsync.password \u4e0d\u7136\u4f20\u8f93\u4f1a\u62a5\u9519`\r\n\r\n#### \u5b9e\u4f8b\uff08\u62c9\u53d6\uff09\r\n`rsync -avz test@192.168.174.128::backup --password-file=\/etc\/rsyncd.password \/tmp\/backup\/`\r\n\r\n#### \u5b9a\u65f6\u62c9\u53d6\r\n\u628a\u62c9\u53d6\u6307\u4ee4\u914d\u7f6e\u5728\u5ba2\u6237\u7aefcrontab\u5373\u53ef\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6545\u4e8b\u80cc\u666f\uff1a\u6211\u4eec\u516c\u53f8\u662f\u505a\u65b0\u96f6\u552e\u7684\uff0c\u9700\u8981\u5bf9\u53d1\u5e03\u7684\u6bcf\u53f0\u673a\u5668\u8fdb\u884c\u6587\u4ef6\u7684\u540c\u6b65\u66f4\u65b0\uff0c\u6240\u4ee5\u6211\u8fd9\u91cc\u505a\u4e86\u4e00\u4e2a\u5c0f\u5c0f\u7684\u8c03\u7814 \u6280\u672f\u8c03\u7814 […]<\/p>\n","protected":false},"author":1466,"featured_media":94943,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-168341","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\/168341","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\/1466"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=168341"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/168341\/revisions"}],"predecessor-version":[{"id":168544,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/168341\/revisions\/168544"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/94943"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=168341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=168341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=168341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}