{"componentChunkName":"component---node-modules-gatsby-theme-gine-blog-src-components-post-blog-post-js","path":"/posts/5a2d705119264dbf99248f0f80a28a21","webpackCompilationHash":"abbc32fa0c65a814f292","result":{"data":{"siteConfig":{"title":"812lcl's Blog","commentDisqusShortname":"812lcl-notion-blog","commentOpen":true},"posts":{"public_date":"2014-05-04","name":"Linux命令学习(2)：rsync","tags":["Linux","rsync"],"html":"<div data-block-id=\"0907acbc-3d03-477b-bfac-ba459a63c874\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 2px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync是Linux下进行文件同步到一个命令，可以同步两台计算机到文件与目录，利用查找文件中到不同块以减少数据传输。也可以在一台电脑到不同目录间同步，比如可以写个简单到脚本，将系统中你到一些配置文件备份到一个 dotfiles 文件夹，上传到 GitHub 以便以后新的电脑或系统再利用 rsync 恢复这些配置文件，这是很方便自动化的（我就是这么干的 <a href=\"https://github.com/812lcl/dotfiles\" style=\"text-decoration:underline;color:inherit;cursor:pointer;word-wrap:break-word\" target=\"_blank\" rel=\"noopener noreferrer\" data-token-index=\"1\">dotfiles</a>)。</div></div></div></div><div data-block-id=\"c200b9ee-bccc-4b5e-92a2-78274d789bec\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync的基本用法</div></div></div><div data-block-id=\"2c7592b0-2744-4703-88f2-37e65c42d700\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">$ rsync [options] src dest<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"48b5aa95-e556-4ded-8b9a-3e663413957e\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">目的端和源端文件内容不同，触发同步</div></div></div></div></div><div data-block-id=\"900e6713-c557-48e5-87da-f622f558fdaf\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync不同步文件到“modify time”，进行同步到文件，目的端到“modify time”总是被修改为最新时刻到时间。</div></div></div></div></div><div data-block-id=\"17b5ba18-e02b-467a-9bc0-a1c7944af753\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync不会太关注目的端文件到rwx权限，如果目的端无此文件，则权限与源端保持一致；如果目的端有此文件，则权限不会随着源端变更。</div></div></div></div></div><div data-block-id=\"c5ac37db-d796-40a3-95a3-5aca13423e9a\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>4.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync有对源文件到读权限，且对目标路径有写权限，rsync就能确保目的端文件同步到和源端一致。</div></div></div></div></div><div data-block-id=\"663edfb5-b131-4221-8e91-e623ffe5605a\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>5.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync只能以登录目的端到帐号来创建文件，无法保持目的端文件到属主和属组和源端一致。</div></div></div></div></div><div data-block-id=\"a5f4bfac-b131-48b7-8146-7c3e8b1cedc2\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-t选项]</div></div></div><div data-block-id=\"f4bf2a03-2247-4f31-89de-333166e2fa76\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">使用-t选项后，rsync总会想着一件事，那就是将源文件的“modify time”同步到目标机器。</div></div></div></div></div><div data-block-id=\"720cdef5-fed5-481a-b125-25fdd3cb0e07\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">带有-t选项的rsync，会变得更聪明些，它会在同步前先对比两边文件的时间戳和文件大小，如果一致，则就认为两边文件一样，对此文件就不再采取更新动作了。</div></div></div></div></div><div data-block-id=\"8e4645e9-366d-4528-b8fe-852d197ea744\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">因为rsync的聪明，也会反被聪明误。如果目的端的文件的时间戳、大小和源端完全一致，但是内容恰巧不一致时，rsync是发现不了的。这就是传说中的“坑”！</div></div></div></div></div><div data-block-id=\"c1c1ab2d-54f9-4786-9f7c-cfff0143f345\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>4.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">对于rsync自作聪明的情况，解决办法就是使用-I选项。</div></div></div></div></div><div data-block-id=\"96e02312-72b1-4a92-8393-65caf2ad18e7\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-I选项]</div></div></div><div data-block-id=\"f494fa36-c4ce-4be3-b568-5d2e211b2ada\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">-I选项会让rsync变得很乖很老实，它会挨个文件去发起数据同步。</div></div></div></div></div><div data-block-id=\"c6f6c93a-7c15-40e8-a87d-44977d22df21\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">-I选项可以确保数据的一致性，代价便是速度上会变慢，因为我们放弃了“quick check”策略。（quick check策略，就是先查看文件的时间戳和文件大小，依次先排除一批认为相同的文件）</div></div></div></div></div><div data-block-id=\"ef54d060-d381-41cf-950c-8bb9adb5c627\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">无论情况如何，目的端的文件的modify time总会被更新到当前时刻。</div></div></div></div></div><div data-block-id=\"e2e6953d-329b-4a4c-aea1-ebba91d6c470\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-v选项]</div></div></div><div data-block-id=\"6306147e-f706-4889-a7d8-ae1493894566\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这个选项，简单易懂，就是让rsync输出更多的信息，你增加越多的v，就可以获得越多的日志信息。</div></div></div></div><div data-block-id=\"6533638b-d2d8-4e2f-b0d5-57a68cd276f3\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-z选项]</div></div></div><div data-block-id=\"275bb31d-1240-457a-8f9f-8eb0b2096bf7\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这是个压缩选项，只要使用了这个选项，rsync就会把发向对端的数据先进行压缩再传输。对于网络环境较差的情况下建议使用。一般情况下，-z的压缩算法会和gzip的一样。</div></div></div></div><div data-block-id=\"7c37e22d-82fc-4cf3-912b-32c8f337e2d5\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-r选项]</div></div></div><div data-block-id=\"a3b6547d-cd9e-4ede-8897-fcd0d34a09e8\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">我们在第一次使用rsync时，往往会遇到这样的囧境：</div></div></div></div><div data-block-id=\"bb6d7a13-aa60-419a-949e-8bc44ff0ff5b\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">$ rsync superman machineB:/home/userB\nskipping directory superman<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"43904141-ab95-4933-a621-24ffa5c59ff5\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">如果你不额外告诉rsync你需要它帮你同步文件夹的话，它是不会主动承担的，这也正是rsync的懒惰之处。所以，如果你真的想同步文件夹，那就要加上-r选项，即recursive（递归的、循环的），像这样：</div></div></div></div><div data-block-id=\"dd451629-eefd-4ccf-9d9e-90abc98ae7f0\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">$  rsync -r superman machineB:/home/userB<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"2ed66dd9-ef1f-4db6-afce-d68baaa0cb94\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">对于文件夹，rsync是会明察秋毫的，只要你加了-r选项，它就会恪尽职守的进入到文件夹里去检查，而不会只对文件夹本身做“quick check”的。</div></div></div></div><div data-block-id=\"4d008ed6-397d-4252-a7ac-ac1f04c4d40f\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-l选项]</div></div></div><div data-block-id=\"b36c04d8-5326-49bc-bd96-ba92f24bc979\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync一旦发现某个文件是软链接，就会无视它，除非我们增加-l选项。使用了-l选项后，rsync会完全保持软链接文件类型，原原本本的将软链接文件复制到目的端，而不会“follow link”到指向的实体文件。如果我偏偏就想让rsync采取follow link的方式，那就用-L选项就可以了。你可以自己试试效果。</div></div></div></div><div data-block-id=\"a8b8b957-e0ff-4eb7-874e-2deb03503351\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-p选项]</div></div></div><div data-block-id=\"fabca6f8-690a-4818-bfd6-3be69e46b3ed\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这个选项的全名是“perserve permissions”，顾名思义，就是保持权限。如果你不使用此选项的话，rsync是这样来处理权限问题的：</div></div></div></div><div data-block-id=\"f03a93b7-db3e-4dea-9a1b-ceecc9b8e85c\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">如果目的端没有此文件，那么在同步后会将目的端文件的权限保持与源端一致；</div></div></div></div></div><div data-block-id=\"8c3c3597-0cd0-4136-8d64-3e41c79b314e\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">如果目的端已存在此文件，那么只会同步文件内容，权限保持原有不变。</div></div></div></div></div><div data-block-id=\"89ae0552-d4cd-4a58-81de-3af0e75be19a\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">如果你使用了-p选项，则无论如何，rsync都会让目的端保持与源端的权限一致的。</div></div></div></div><div data-block-id=\"dfd85d56-4b5b-418b-9644-9ccf4b2b3f20\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-g选项和-o选项]</div></div></div><div data-block-id=\"85ce4fcf-fbae-428d-81cf-3628e59e449b\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这两个选项是一对，用来保持文件的属组(group)和属主（owner），作用应该很清晰明了。不过要注意的一点是，改变属主和属组，往往只有管理员权限才可以。</div></div></div></div><div data-block-id=\"b7f5305f-4f9d-4a6e-bf20-dd3c7ebe90db\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-D选项]</div></div></div><div data-block-id=\"b2d1a080-a1f0-4dc1-b1ce-8282c5ca7c85\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">-D选项，原文解释是“preserve devices(root only)”，从字面意思看，就是保持设备文件的原始信息。</div></div></div></div><div data-block-id=\"77292d5f-b071-40af-90a1-c02ef785e848\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[-a选项]</div></div></div><div data-block-id=\"a1d9d579-aa88-4661-8b5d-78572e5becfb\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">-a选项是rsync里比较霸道的一个选项，因为你使用-a选项，就相当于使用了<span style=\"font-family:&quot;SFMono-Regular&quot;, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace;line-height:normal;background:rgba(135,131,120,0.15);color:#EB5757;border-radius:3px;font-size:85%;padding:0.2em 0.4em\" data-token-index=\"1\">-rlptgoD</span>这一坨选项。以一敌七，唯-a选项也。</div></div></div></div></div><div data-block-id=\"8246d956-3e3e-4dab-95c6-0d1f5404c317\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">-a选项的学名应该叫做archive option，中文叫做归档选项。使用-a选项，就表明你希望采取递归方式来同步，且尽可能的保持各个方面的一致性。</div></div></div></div></div><div data-block-id=\"b41e38a6-5920-464c-9196-3b7fb91564c9\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">但是-a无法同步“硬链接”情况。如果有这方面需求，要加上-H选项。</div></div></div></div></div><div data-block-id=\"dd7247c9-4565-47ff-889f-e8a087169cda\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[–delete选项、–delete-excluded选项和–delete-after选项]</div></div></div><div data-block-id=\"abc4bccd-17a9-4c03-b02d-c673762ad876\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">三个选项都是和“删除”有关的：</div></div></div></div><div data-block-id=\"c1be0275-f058-4b9a-bb3d-15fcee1f7aec\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">–delete：如果源端没有此文件，那么目的端也别想拥有，删除之。（如果你使用这个选项，就必须搭配-r选项一起）</div></div></div></div></div><div data-block-id=\"f6e20fb9-b180-44e7-8274-de2a6c7880a9\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">–delete-excluded：专门指定一些要在目的端删除的文件。</div></div></div></div></div><div data-block-id=\"2f08e191-eb7b-468e-a9e3-7d9f9ae17858\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">–delete-after：默认情况下，rsync是先清理目的端的文件再开始数据同步；如果使用此选项，则rsync会先进行数据同步，都完成后再删除那些需要清理的文件。</div></div></div></div></div><div data-block-id=\"6debaa2a-9221-4370-97e2-e6d9c75aee8b\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这个学习可是要小心使用到，一不小心会删除很多东西哦。</div></div></div></div><div data-block-id=\"3f63e432-312a-4a7c-9c73-c674fbc22463\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">可以使用-n选项，它会用受影响的文件列表来警告你，但不会真的去删除，这就让我们有了确认的机会和回旋的余地。</div></div></div></div><div data-block-id=\"2f66bdf1-1620-4777-9a9a-2109205f71de\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[–exclude选项和–exclude-from选项]</div></div></div><div data-block-id=\"d82429f3-071e-4128-a7b2-8513852dd8ee\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">如果你不希望同步一些东西到目的端的话，可以使用–exclude选项来隐藏，rsync还是很重视大家隐私的，你可以多次使用–exclude选项来设置很多的“隐私”。 如果你要隐藏的隐私太多的话，在命令行选项中设置会比较麻烦，rsync还是很体贴，它提供了–exclude-from选项，让你可以把隐私一一列在一个文件里，然后让rsync直接读取这个文件就好了。</div></div></div></div><div data-block-id=\"7d5a289c-e98a-4f10-8355-6b92bd7c2d36\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[–partial选项]</div></div></div><div data-block-id=\"49488f9d-881a-4967-b791-a45b5fe7eeb1\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这就是传说中的断点续传功能。默认情况下，rsync会删除那些传输中断的文件，然后重新传输。但在一些特别情况下，我们不希望重传，而是续传。 我们在使用中，经常会看到有人会使用-P选项，这个选项其实是为了偷懒而设计的。以前人们总是要手动写–partial –progress，觉得太费劲了，倒不如用一个新的选项来代替，于是-P应运而生了。</div></div></div></div><div data-block-id=\"3a43a0d3-650f-4670-858a-1d8d430deae0\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[–progress选项]</div></div></div><div data-block-id=\"5535062b-0507-43c6-a9c8-68c1245268c7\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">使用这个选项，rsync会显示出传输进度信息，有什么用呢，rsync给了一个很有意思的解释： This gives a bored user something to watch.</div></div></div></div><div data-block-id=\"3c43a17d-21e9-47a9-acd9-e13a52de0f31\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync核心算法</div></div></div><div data-block-id=\"c13c45b2-2043-490d-ac9f-1e27748fc782\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync的算法十分高效，酷壳上 <a href=\"http://coolshell.cn/articles/7425.html\" style=\"text-decoration:underline;color:inherit;cursor:pointer;word-wrap:break-word\" target=\"_blank\" rel=\"noopener noreferrer\" data-token-index=\"1\">一篇文章</a> 介绍来其核心算法，就不再赘述来。</div></div></div></div><div data-block-id=\"8fa180b6-2a1a-45e3-acd2-89e75fc1251f\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">##rsync服务器架设 可以架设rsync服务器，rsync以守护进程运行，客户端将rsync指令写成一个shell脚本，通过crontab定期执行脚本，以实现服务器和客户端间特定文件或目录到同步，这样就不需要你每次手动同步来，而且rsync服务器配置也十分简单。</div></div></div></div><div data-block-id=\"bf433360-0ab6-41f8-9163-669711b241dd\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">主要涉及三个文件：</div></div></div></div><div data-block-id=\"24113059-62fb-45b6-a846-3d331a8b4058\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">/etc/rsyncd.conf 是rsync服务器主要配置文件</div></div></div></div></div><div data-block-id=\"68373243-2da5-4ae2-8818-b43e401ed2f5\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">/etc/rsyncd.secrets 是登录rsync服务器到密码文件</div></div></div></div></div><div data-block-id=\"1df737d8-af62-4334-bfc4-05473a324172\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">/etc/rsyncd.motd 是定义用户登录时显示到信息</div></div></div></div></div><div data-block-id=\"e2f61fc7-e6a3-4aae-a6c4-7c95794091c6\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsyncd.conf</div></div></div><div data-block-id=\"24aff622-6cf2-4b6a-8dd4-4a691d90385d\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">文件内容大体如下：</div></div></div></div><div data-block-id=\"5a1c4a96-ca37-4716-a879-3775e5ac4f2f\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\"># Minimal configuration file for rsync daemon\n# See rsync(1) and rsyncd.conf(5) man pages for help\n\n# This line is required by the /etc/init.d/rsync script\npid file = /var/run/rsyncd.pid\nmotd file = /etc/rsyncd.motd\nport = 873\naddress = 192.168.20.24\n#uid = nobody\n#gid = nobody\nuid = root\ngid = root\nuse chroot = yes\nread only = no\n\n# limit access to private LANs\nhosts allow = *\nhosts deny = *\n\nmax connections = 5\n\n# This will give you a separate log file\nlog file = /var/log/rsync.log\n\n# This will log every file transferred - up to 85,000+ per user, per sync\n# transfer logging = yes\n\nlog format = %t %a %m %f %b\nsyslog facility = local3\ntimeout = 300\n\n[test]\npath = /home/lcl/test\nlist = yes\nignore errors\nauth users = lcl\nsecrets file = /etc/rsyncd.secrets\ncomment = lcl test\n#exclude = samba/<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"f43cfb0f-13e5-415d-86dd-f7cc4c06f134\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync使用到是873好端口，上面到配置中<span style=\"font-family:&quot;SFMono-Regular&quot;, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace;line-height:normal;background:rgba(135,131,120,0.15);color:#EB5757;border-radius:3px;font-size:85%;padding:0.2em 0.4em\" data-token-index=\"1\">hosts allow</span>是允许使用这台rsync服务到机器到IP地址，<span style=\"font-family:&quot;SFMono-Regular&quot;, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace;line-height:normal;background:rgba(135,131,120,0.15);color:#EB5757;border-radius:3px;font-size:85%;padding:0.2em 0.4em\" data-token-index=\"3\">hosts deny</span>则是拒绝到，不同IP以空格隔开。</div></div></div></div><div data-block-id=\"93560a20-b1f5-446f-bb0f-93496523b621\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">[test]及之后到配置则是，配置rsync目录，包括目录到路径，使用到用户，密码文件，可以使用<span style=\"font-family:&quot;SFMono-Regular&quot;, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace;line-height:normal;background:rgba(135,131,120,0.15);color:#EB5757;border-radius:3px;font-size:85%;padding:0.2em 0.4em\" data-token-index=\"1\">exclude</span>排除不要同步到文件或目录。</div></div></div></div><div data-block-id=\"a9eb5e3c-f1bc-482d-aea6-0e51f6099985\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsyncd.secrets</div></div></div><div data-block-id=\"7478afda-f532-45a0-9bf5-8170085652b7\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">这是存储rsync服务用户到用户名和密码，是一个明文文本文件，非常重要，属性需要设为600，只允许所有者读写，文件格式如下：</div></div></div></div><div data-block-id=\"a92b4646-0740-4347-a667-5b4f171b3258\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">lcl:12345<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"201ef590-c8fe-43e6-8c2e-5ffea56d7dcf\" class=\"notion-selectable notion-sub_sub_header-block\" style=\"width: 100%; max-width: 608px; margin-top: 1em; margin-bottom: 1px; color: rgb(55, 53, 47);\"><div style=\"display: flex; width: 100%; font-weight: 600; font-size: 1.25em; line-height: 1.3; color: inherit; fill: inherit;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"Heading 3\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsyncd.motd</div></div></div><div data-block-id=\"2f2e76db-7555-478d-839d-8776688f11a2\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">文件记录来rsync服务到欢迎信息，当用户使用该服务时会显示，可以设置为任何文本信息，如：</div></div></div></div><div data-block-id=\"582b9015-ce0a-433a-8734-3d238ce855f2\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">++++++++++++++++++++++++++++++++++++++\n+ Welcome to use lcl rsync services! +\n++++++++++++++++++++++++++++++++++++++<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"7f169c10-8231-4160-8b1d-00cb6c448188\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">配置完以上文件，可以启动rsync服务来：</div></div></div></div><div data-block-id=\"f36bda37-1a5c-4955-a991-076059b1f6af\" class=\"notion-selectable notion-code-block\" style=\"width: 100%; max-width: 608px; margin-top: 4px; margin-bottom: 4px;\"><div style=\"display: flex;\"><div style=\"flex-grow: 1; border-radius: 3px; text-align: left; position: relative; background: rgb(247, 246, 243); min-width: 0px; width: 100%;\"><div class=\"line-numbers notion-code-block\" style=\"display: flex; overflow-x: auto;\"><div contenteditable=\"false\" spellcheck=\"false\" autocorrect=\"off\" autocapitalize=\"off\" data-root=\"true\" style=\"flex-grow: 1; flex-shrink: 1; text-align: left; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 85%; tab-size: 2; padding: 30px 16px 30px 20px; min-height: 1em; color: rgb(55, 53, 47); white-space: pre;\">rsync --daemon<span>\n</span></div></div><div style=\"position: absolute; top: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"></div><div style=\"position: absolute; bottom: 0px; right: 0px; color: rgba(55, 53, 47, 0.6); display: flex; align-items: center; justify-content: flex-end; height: 30px;\"><div role=\"button\" aria-disabled=\"true\" tabindex=\"-1\" style=\"user-select: none; transition: background 120ms ease-in 0s; display: inline-flex; align-items: center; white-space: nowrap; height: 20px; border-radius: 3px; font-size: 12px; line-height: 1.2; padding-left: 5px; padding-right: 5px; color: rgba(55, 53, 47, 0.6); margin-right: 5px;\">Plain Text<svg viewBox=\"0 0 30 30\" class=\"chevronDown\" style=\"width: 10px; height: 100%; display: block; fill: rgba(55, 53, 47, 0.3); flex-shrink: 0; backface-visibility: hidden; margin-left: 4px;\"><polygon points=\"15,17.4 4.8,7 2,9.8 15,23 28,9.8 25.2,7 \"></polygon></svg></div></div></div></div></div><div data-block-id=\"47eecedb-ec88-4dbd-a09f-325838e3756f\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">客户端可以通过rsync命令活脚本来进行同步数据来</div></div></div></div><div data-block-id=\"2cbe3e1f-ab71-44cf-b84f-18c94336db9b\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync的命令格式可以为：</div></div></div></div><div data-block-id=\"1486b8aa-ee5a-4675-9d0d-581a5a834b50\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… SRC [SRC]… [USER@]HOST:DEST]</div></div></div></div></div><div data-block-id=\"3da4c686-441b-4fd9-bf6c-42e1225b318c\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… [USER@]HOST:SRC DEST]</div></div></div></div></div><div data-block-id=\"2c8d9773-581b-48de-97d0-a67f96d3f456\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… SRC [SRC]… DEST]</div></div></div></div></div><div data-block-id=\"c6c4b508-c93b-48fe-973a-8af46a07f50f\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>4.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… [USER@]HOST::SRC [DEST]</div></div></div></div></div><div data-block-id=\"58ff81a4-47af-4857-ba85-34f738821ac8\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>5.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… SRC [SRC]… [USER@]HOST::DEST]</div></div></div></div></div><div data-block-id=\"aae35c8f-75ef-4f6b-8c00-b330db87dd04\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>6.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">rsync [OPTION]… rsync://[USER@]HOST[:PORT]/SRC [DEST]</div></div></div></div></div><div data-block-id=\"388b1873-62bf-4477-aa8a-f4e23f4df879\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">rsync有六种不同的工作模式：</div></div></div></div><div data-block-id=\"af6f7c5d-7e7d-4997-a64d-26b4ee9d2531\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>1.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">拷贝本地文件；当SRC和DES路径信息都不包含有单个冒号“:”分隔符时就启动这种工作模式。</div></div></div></div></div><div data-block-id=\"b90d983b-af95-46e3-a7da-c9e2b16a57d2\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>2.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">使用一个远程shell程序（如rsh、ssh）来实现将本地机器的内容拷贝到远程机器。当DST地址包含单个冒号“:”分隔符时启动该模式。</div></div></div></div></div><div data-block-id=\"68ac32b3-6b8a-4c46-810c-04628486a5e0\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>3.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">使用一个远程shell程序（如rsh、ssh）来实现将远程机器的内容拷贝到本地机器。当SRC路径包含单个冒号“:”分隔符时启动该模式。</div></div></div></div></div><div data-block-id=\"3a472d78-a731-49e3-8d06-9d88e03d12d0\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>4.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">从远程rsync服务器中拷贝文件到本地机。当SRC路径信息包含“::”分隔符时启动该模式。</div></div></div></div></div><div data-block-id=\"052847df-ff9a-4c1f-aa43-0e4b1c9efb51\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>5.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">从本地机器拷贝文件到远程rsync服务器中。当DST路径信息包含“::”分隔符时启动该模式。</div></div></div></div></div><div data-block-id=\"e1a1916d-05fa-4db1-97f1-a75d39334ea9\" class=\"notion-selectable notion-numbered_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px);\"><span>6.</span></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\">列远程机的文件列表。这类似于rsync传输，不过只要在命令中省略掉本地机信息即可。</div></div></div></div></div><div data-block-id=\"442baf3c-4d44-4a98-86b7-848ceec9ffe9\" class=\"notion-selectable notion-text-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"color: inherit; fill: inherit;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\" \" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding: 3px 2px;\">参考文章：</div></div></div></div><div data-block-id=\"4ec19096-3d73-42b5-a1e8-e13878778f74\" class=\"notion-selectable notion-bulleted_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 1px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px); padding-right: 2px;\"><div style=\"width: 6px; height: 6px; border-radius: 6px; background: currentcolor; margin-top: 0.1em;\"></div></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\"><a href=\"http://roclinux.cn/?p=2643\" style=\"text-decoration:underline;color:inherit;cursor:pointer;word-wrap:break-word\" target=\"_blank\" rel=\"noopener noreferrer\" data-token-index=\"0\">rsync同步的艺术</a></div></div></div></div></div><div data-block-id=\"73965616-80d6-40a7-b2b1-fcd391b107fb\" class=\"notion-selectable notion-bulleted_list-block\" style=\"width: 100%; max-width: 608px; margin-top: 1px; margin-bottom: 0px;\"><div style=\"display: flex; align-items: flex-start; width: 100%; padding-left: 2px; color: inherit; fill: inherit;\"><div style=\"margin-right: 4px; width: 24px; display: flex; align-items: center; justify-content: center; flex-grow: 0; flex-shrink: 0; min-height: calc((1.5em + 3px) + 3px); padding-right: 2px;\"><div style=\"width: 6px; height: 6px; border-radius: 6px; background: currentcolor; margin-top: 0.1em;\"></div></div><div style=\"flex: 1 1 0px; min-width: 1px; display: flex; flex-direction: column;\"><div style=\"display: flex;\"><div contenteditable=\"false\" spellcheck=\"true\" placeholder=\"List\" data-root=\"true\" style=\"max-width: 100%; width: 100%; white-space: pre-wrap; word-break: break-word; caret-color: rgb(55, 53, 47); padding-top: 3px; padding-bottom: 3px; text-align: left;\"><a href=\"https://www.centos.bz/2011/06/rsync-server-setup\" style=\"text-decoration:underline;color:inherit;cursor:pointer;word-wrap:break-word\" target=\"_blank\" rel=\"noopener noreferrer\" data-token-index=\"0\">rsync服务器架设（数据同步|文件增量备份)</a></div></div></div></div></div>","slug":"5a2d705119264dbf99248f0f80a28a21","keywords":["博客"]}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"5a2d705119264dbf99248f0f80a28a21"}}}