両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
linux:rsync [2025/02/26 17:46] – [rsyncとsshを利用したリモートサーバの高速バックアップ] ともやん | linux:rsync [2025/04/24 04:39] (現在) – [除外パターンを bash braces '{}' で効率よく書く✍😍] ともやん |
---|
</pre></html></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |
| |
| ===== 除外 [--exclude] ===== |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">rsync</font> <font color="#A347BA">-rtlzvogpHAXP</font> <font color="#A347BA">--delete</font> <font color="#A347BA">--exclude</font> <u style="text-decoration-style:solid">/dev/</u> <font color="#A347BA">--exclude</font> <u style="text-decoration-style:solid">/proc/</u> <font color="#A347BA">--exclude</font> <u style="text-decoration-style:solid">/sys/</u> <font color="#A347BA">--exclude</font> <u style="text-decoration-style:solid">/var/run/</u> <font color="#A347BA">--exclude</font> <u style="text-decoration-style:solid">/var/lock/</u> <font color="#A347BA">--exclude</font> ifcfg<font color="#12488B"><b>*</b></font> <font color="#A347BA">--exclude</font> ssh_host_<font color="#12488B"><b>*</b></font> <font color="#A347BA">--exclude</font> fstab <font color="#A347BA">--block-size=4096</font> <font color="#A347BA">-e</font> <font color="#A2734C">"ssh -p12345"</font> <u style="text-decoration-style:solid">/</u> skv0001:/ |
| </pre></html></WRAP> |
| </WRAP> |
| <html><code>--exclude [パターン]</code></html> パターンに一致するものを除外する🤔\\ |
| [[.rsync:fedora_vps_duplicate|Fedora VPS サーバーを rsync で複製する😍]] のような場合に活躍するオプション😉\\ |
| |
| ==== 除外パターンを bash braces '{}' で効率よく書く✍😍 ==== |
| ''%%--%%exclude data/log'' ではなく ''%%--%%exclude=data/log'' で書く必要がある🤔\\ |
| ''%%--%%exclude\ data/log'' スペースをバックスラッシュでエスケープすると、bash はブレース展開をシングルクオートで囲むので rsync で **rsync error: syntax or usage error** になるからである🤔\\ |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">rsync</font> <font color="#A347BA">-avzP</font> <font color="#A347BA">--delete</font> \ |
| <font color="#A347BA">--exclude=</font><font color="#2A7BDE"><b>{</b></font><font color="#A347BA">data/log,lib/plugins/codemirror,lib/tpl/tomoyannet,lib/tpl/tomoyannet_lite</font><font color="#2A7BDE"><b>}</b></font> \ |
| <font color="#A347BA">--exclude=data/cache/</font><font color="#2A7BDE"><b>{</b></font><font color="#33D17A"><b>{</b></font><font color="#A347BA">0..9</font><font color="#33D17A"><b>}</b></font><font color="#A347BA">,</font><font color="#33D17A"><b>{</b></font><font color="#A347BA">a..f</font><font color="#33D17A"><b>}</b></font><font color="#2A7BDE"><b>}</b></font> \ |
| <font color="#A347BA">-e</font> ssh \ |
| skv0001://var/www/vhosts/www.tomoyan.net/dokuwiki/ \ |
| <u style="text-decoration-style:solid">~/my_projects/tomoyan.net/sites/tomoyan.net/dokuwiki</u> |
| </pre></html></WRAP> |
| ↓ |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>+</b></font> <font color="#26A269">rsync</font> <font color="#A347BA">-avzP</font> <font color="#A347BA">--delete</font> \ |
| <font color="#A347BA">--exclude</font>=data/log <font color="#A347BA">--exclude</font>=lib/plugins/codemirror <font color="#A347BA">--exclude</font>=lib/tpl/tomoyannet <font color="#A347BA">--exclude=</font>=lib/tpl/tomoyannet_lite \ |
| <font color="#A347BA">--exclude=</font>=data/cache/0 <font color="#A347BA">--exclude</font>=data/cache/1 <font color="#A347BA">--exclude</font>=data/cache/2 <font color="#A347BA">--exclude</font>=data/cache/3 <font color="#A347BA">--exclude</font>=data/cache/4 <font color="#A347BA">--exclude</font>=data/cache/5 <font color="#A347BA">--exclude</font>=data/cache/6 <font color="#A347BA">--exclude</font>=data/cache/7 <font color="#A347BA">--exclude</font>=data/cache/8 <font color="#A347BA">--exclude</font>=data/cache/9 <font color="#A347BA">--exclude</font>=data/cache/a <font color="#A347BA">--exclude</font>=data/cache/b <font color="#A347BA">--exclude</font>=data/cache/c <font color="#A347BA">--exclude</font>=data/cache/d <font color="#A347BA">--exclude</font>=data/cache/e <font color="#A347BA">--exclude</font>=data/cache/f \ |
| -e ssh \ |
| skv0001://var/www/vhosts/www.tomoyan.net/dokuwiki/ \ |
| /home/tomoyan/my_projects/tomoyan.net/sites/tomoyan.net/dokuwiki |
| </pre></html></WRAP> |
| </WRAP> |
| |
| [[dt>rpalo/bash-brackets-quick-reference-4eh6|Bash Brackets Quick Reference - DEV Community]] [[gtr>https://dev.to/rpalo/bash-brackets-quick-reference-4eh6|翻訳]]\\ |
| |
===== 冗長でくどい Verbose ...😅 ===== | ===== 冗長でくどい Verbose ...😅 ===== |
[[md>@saksenaprashant06/the-algorithm-behind-rsync-76c66a278152|The Algorithm behind Rsync. “we want algorithms that are good in… | by Prashant Saksena | Medium]]\\ | [[md>@saksenaprashant06/the-algorithm-behind-rsync-76c66a278152|The Algorithm behind Rsync. “we want algorithms that are good in… | by Prashant Saksena | Medium]]\\ |
要約するとA, B間でブロック署名をやり取りして、ブロックごとに差分のみを高速転送するアルゴリズムだから...🤔\\ | 要約するとA, B間でブロック署名をやり取りして、ブロックごとに差分のみを高速転送するアルゴリズムだから...🤔\\ |
| |
| ===== レシピ ===== |
| [[.rsync:fedora_vps_duplicate|Fedora VPS サーバーを rsync で複製する😍]]\\ |
| |
===== トラブルシューティング ===== | ===== トラブルシューティング ===== |