rsync 只同步特定格式/副檔名檔案的方法

想要用 rsync 同步特定格式的檔案,最近比較沒空動腦認真想,只好 Google 找現成的答案,在 stackoverflow 和 Ubuntu forums 看到的方法,很實用:

http://ubuntuforums.org/showthread.php?t=763833&p=8546521#post8546521

https://stackoverflow.com/a/11111793

[bash]
rsync -a –include ‘*/’ –include ‘*.mp3’ –exclude ‘*’ source/ target/
[/bash]

看 stackoverflow 那邊討論是寫 rsync 3.0.7 以前的版本的用法要這樣寫,那個 exclude 和 include 的順序有影響 :

[bash]
rsync -a –include ‘*/’ –exclude ‘*’ –include ‘*.mp3’ source/ target/
[/bash]

不過我自己是沒特別測試過就是了,隨手翻了一下 change log 好像沒看到相關的說明:

所以不確定是不是真的從 rsync v3.0.7 改了用法還是怎麼樣,等哪天有空再來翻翻看 …

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。