{"id":5575,"date":"2014-05-06T21:32:36","date_gmt":"2014-05-06T13:32:36","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=5575"},"modified":"2018-10-12T21:30:17","modified_gmt":"2018-10-12T13:30:17","slug":"%e4%bd%bf%e7%94%a8rsync%e5%90%8c%e6%ad%a5%e5%a4%87%e4%bb%bd%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/5575.html","title":{"rendered":"\u4f7f\u7528rsync\u540c\u6b65\u5907\u4efd\u6587\u4ef6"},"content":{"rendered":"<p>\u5b89\u88c5rsync\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install rsync\r\n<\/pre>\n<p>\u7f16\u8f91server\u7684\u914d\u7f6e\u6587\u4ef6\uff0cvim \/etc\/rsyncd.conf\uff0c<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n# sample rsyncd.conf configuration file\r\n\r\n# GLOBAL OPTIONS\r\n\r\n#motd file=\/etc\/motd\r\nlog file=\/var\/log\/rsyncd.log\r\n# for pid file, do not use \/var\/run\/rsync.pid if\r\n# you are going to run rsync out of the init.d script.\r\n# pid file=\/var\/run\/rsyncd.pid\r\n#syslog facility=daemon\r\n#socket options=\r\n\r\n# MODULE OPTIONS\r\nuid = root\r\ngid = root\r\naddress = 192.168.2.30\r\nread only = no\r\nlist=yes\r\nignore errors\r\nauth users=root\r\nsecrets file = \/etc\/rsyncd.secrets\r\n\r\n&#x5B;etc]\r\n\r\n    path = \/etc\/\r\n\r\n&#x5B;opt_share]\r\n\r\n    path = \/opt\/share\/\r\n<\/pre>\n<p>\u793a\u4f8b\u914d\u7f6e\u8bf4\u660e\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n######################################################################################################\r\n#                      ******\u8fdb\u7a0b\u76f8\u5173\u5168\u5c40\u914d\u7f6e******\r\n######################################################################################################\r\n# = \u540e\u9762\u7684\u503c\u53ef\u6839\u636e\u81ea\u5df1\u7684\u5b9e\u9645\u60c5\u51b5\u66f4\u6539\r\n#    pid file \u5b88\u62a4\u8fdb\u7a0bpid\u6587\u4ef6\r\n#    port \u5b88\u62a4\u8fdb\u7a0b\u76d1\u542c\u7aef\u53e3\uff0c\u53ef\u66f4\u6539\uff0c\u7531xinetd\u5141\u8bb8rsyncd\u65f6\u5ffd\u7565\u6b64\u53c2\u6570\r\n#    address \u5b88\u62a4\u8fdb\u7a0b\u76d1\u542cip\uff0c\u7531xinetd\u5141\u8bb8rsyncd\u65f6\u5ffd\u7565\u6b64\u53c2\u6570\r\npid file = \/usr\/local\/var\/run\/rsyncd.pid\r\nport = 873\r\naddress = 192.168.1.2\r\n#rsyncd \u5b88\u62a4\u8fdb\u7a0b\u8fd0\u884c\u7cfb\u7edf\u7528\u6237\u5168\u5c40\u914d\u7f6e\uff0c\u4e5f\u53ef\u5728\u5177\u4f53\u7684\u5757\u4e2d\u72ec\u7acb\u914d\u7f6e,\r\nuid = root\r\ngid = root\r\n#\u5141\u8bb8 chroot\uff0c\u63d0\u5347\u5b89\u5168\u6027\uff0c\u5ba2\u6237\u7aef\u8fde\u63a5\u6a21\u5757\uff0c\u9996\u5148chroot\u5230\u6a21\u5757path\u53c2\u6570\u6307\u5b9a\u7684\u76ee\u5f55\u4e0b\r\n#chroot\u4e3ayes\u65f6\u5fc5\u987b\u4f7f\u7528root\u6743\u9650\uff0c\u4e14\u4e0d\u80fd\u5907\u4efdpath\u8def\u5f84\u5916\u7684\u94fe\u63a5\u6587\u4ef6\r\nuse chroot = yes\r\n#\u53ea\u8bfb\r\nread only = no\r\n#\u53ea\u5199\r\nwrite only = no\r\n#\u5141\u8bb8\u8bbf\u95eersyncd\u670d\u52a1\u7684ip\uff0cip\u7aef\u6216\u8005\u5355\u72ecip\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u9694\u5f00\r\nhosts allow = 192.168.0.1\/255.255.255.0 198.162.145.1 10.0.1.0\/255.255.255.0\r\n#\u4e0d\u5141\u8bb8\u8bbf\u95eersyncd\u670d\u52a1\u7684ip\uff0c*\u662f\u5168\u90e8(\u4e0d\u6db5\u76d6\u5728hosts allow\u4e2d\u58f0\u660e\u7684ip\uff0c\u6ce8\u610f\u548chosts allow\u7684\u5148\u540e\u987a\u5e8f)\r\nhosts deny = *\r\n#\u5ba2\u6237\u7aef\u6700\u5927\u8fde\u63a5\u6570\r\nmax connections = 5\r\n#\u6b22\u8fce\u6587\u4ef6\u8def\u5f84\uff0c\u53ef\u9009\u7684\r\n#motd file = \/etc\/rsyncd\/rsyncd.motd\r\n#\u65e5\u5fd7\u76f8\u5173\r\n#    log file \u6307\u5b9arsync\u53d1\u9001\u6d88\u606f\u65e5\u5fd7\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u53d1\u9001\u7ed9syslog\uff0c\u5982\u679c\u4e0d\u586b\u8fd9\u4e2a\u53c2\u6570\u9ed8\u8ba4\u53d1\u9001\u7ed9syslog\r\n#    transfer logging \u662f\u5426\u8bb0\u5f55\u4f20\u8f93\u6587\u4ef6\u65e5\u5fd7\r\n#    log format \u65e5\u5fd7\u6587\u4ef6\u683c\u5f0f\uff0c\u683c\u5f0f\u53c2\u6570\u8bf7google\r\n#    syslog facility rsync\u53d1\u9001\u6d88\u606f\u7ed9syslog\u65f6\u7684\u6d88\u606f\u7ea7\u522b\uff0c\r\n#    timeout\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\r\nlog file = \/usr\/local\/logs\/rsyncd.log\r\ntransfer logging = yes\r\nlog format = %t %a %m %f %b\r\nsyslog facility = local3\r\ntimeout = 300\r\n\r\n######################################################################################################\r\n#                      ******\u6a21\u5757\u914d\u7f6e(\u591a\u4e2a)******\r\n######################################################################################################\r\n#\u6a21\u5757 \u6a21\u5757\u540d\u79f0\u5fc5\u987b\u4f7f\u7528&#x5B;]\u73af\u7ed5\uff0c\u6bd4\u5982\u8981\u8bbf\u95eedata1,\u5219\u5730\u5740\u5e94\u8be5\u662fdata1user@192.168.1.2::data1\r\n&#x5B;data1]\r\n#\u6a21\u5757\u6839\u76ee\u5f55\uff0c\u5fc5\u987b\u6307\u5b9a\r\npath=\/home\/username\r\n#\u662f\u5426\u5141\u8bb8\u5217\u51fa\u6a21\u5757\u91cc\u7684\u5185\u5bb9\r\nlist=yes\r\n#\u5ffd\u7565\u9519\u8bef\r\n#ignore errors\r\n#\u6a21\u5757\u9a8c\u8bc1\u7528\u6237\u540d\u79f0\uff0c\u53ef\u4f7f\u7528\u7a7a\u683c\u6216\u8005\u9017\u53f7\u9694\u5f00\u591a\u4e2a\u7528\u6237\u540d\r\nauth users = data1user\r\n#\u6a21\u5757\u9a8c\u8bc1\u5bc6\u7801\u6587\u4ef6 \u53ef\u653e\u5728\u5168\u5c40\u914d\u7f6e\u91cc\r\nsecrets file=\/etc\/rsyncd\/rsyncd.secrets\r\n#\u6ce8\u91ca\r\ncomment = some description about this moudle\r\n#\u6392\u9664\u76ee\u5f55\uff0c\u591a\u4e2a\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u9694\u5f00\r\nexclude = test1\/ test2\/\r\n<\/pre>\n<p>\u5728\u5ba2\u6237\u7aef\u4e0a\u9762\u540c\u6b65\u547d\u4ee4\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n#!\/bin\/bash\r\necho -e '\\r------sync etc...\\r'\r\nrsync -avzPrh --progress root@192.168.2.30::etc \/mnt\/sdb2\/etc\/\r\necho -e '\\r------sync share...\\r'\r\nrsync -avzPrh --password-file=sync.secrets --progress root@192.168.2.30::opt_share \/mnt\/sdb2\/opt\/share\/\r\n\r\n<\/pre>\n<h3>\u6ce8\u610f\u914d\u7f6e\u7528\u6237\u540d\u4e0e\u5bc6\u7801\u7684\u65f6\u5019\uff1a<\/h3>\n<ol>\n<li>\u5fc5\u987b\u8bbe\u7f6e\u00a0auth users \u53c2\u6570\uff0c\u4e0d\u7136&#8211;password-file\u53c2\u6570\u4e0d\u8d77\u4f5c\u7528\u3002<\/li>\n<li>&#8211;password-file \u6307\u5b9a\u7684\u6587\u4ef6\u5185\u5bb9\u683c\u5f0f\u4e3a user:password<\/li>\n<li>&#8211;password-file \u6307\u5b9a\u7684\u6587\u4ef6\u6743\u9650\u8981\u8bbe\u7f6e\u6210 600<\/li>\n<li>rysnc \u5ba2\u6237\u7aef\u6307\u5b9a\u7684 &#8211;password-file\u6587\u4ef6\u5185\u5bb9\u4ec5\u4ec5\u53ea\u9700\u8981\u5199\u4e0apassword\uff0c\u7528\u6237\u540d\u5df2\u7ecf\u5728\u00a0root@192.168.2.30 \u8fd9\u91cc\u6307\u5b9a\u4e86<\/li>\n<li>rsync \u5ba2\u6237\u7aef\u7684\u00a0&#8211;password-file\u6587\u4ef6\uff0c\u4e00\u6837\u8981\u8bbe\u7f6e\u6743\u9650\u4e3a600<\/li>\n<\/ol>\n<p>\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/download.samba.org\/pub\/rsync\/rsyncd.conf.html\">https:\/\/download.samba.org\/pub\/rsync\/rsyncd.conf.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5rsync\uff1a sudo apt-get install rsync \u7f16\u8f91server\u7684\u914d\u7f6e\u6587\u4ef6\uff0cvim \/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-5575","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=5575"}],"version-history":[{"count":5,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5575\/revisions"}],"predecessor-version":[{"id":6762,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/5575\/revisions\/6762"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=5575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=5575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=5575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}