* .phpファイルのみをスキャンしている間、rsync除外ディレクトリは機能しません。

* .phpファイルのみをスキャンしている間、rsync除外ディレクトリは機能しません。

/home/内のすべてのディレクトリにあるすべての.PHPファイルと.HTMLファイルを同期しようとしています。しかし、/home/site2/public_html/cache_old/には、同期に含めたくないいくつかの.htmlファイルがあります。したがって、そのディレクトリとそのサブディレクトリを除外したいと思います。

これは私が考えることができる最高のrsyncコマンドです(多くのテストと失敗の後)。

rsync -avv /home/ /ssd/rsyncPHPsFORmtree/ --include '*/' --include '*.html' --include '*.php' --exclude /site2/public_html/cache_old/* --exclude '*'

rsyncが実行されたときの出力によると、私のrsyncコマンドの形式が間違っていると確信しています。

[sender] showing file site2/public_html/cache_old/total_pages/s/e/a/r/c/page99.html because of pattern *.html

[sender] showing file site2/public_html/cache_old/total_pages/s/e/a/r/c/Page4.html because of pattern *.html

[sender] showing file site2/public_html/cache_old/total_pages/s/e/a/r/c/searchHe107.html because of pattern *.html

[sender] showing file site2/public_html/cache_old/total_pages/s/e/a/r/c/page18.html because of pattern *.html

ありがとう

ベストアンサー1

rsync -avv /home/ /ssd/rsyncPHPsFORmtree/ --exclude '/site2/public_html/cache_old/' --include '*.html' --include '*.php' --include '*/' --exclude '*'  

これはトリックを行う必要があります。
ファイラーの順序が重要です。最初の一致ルールが適用されます。したがって、まずフォルダを除外し、必要なファイルを含め、次に以前に除外されていないディレクトリを含め、他のすべての項目を除外します。

おすすめ記事