顯示具有 rsync 標籤的文章。 顯示所有文章
顯示具有 rsync 標籤的文章。 顯示所有文章

2018年12月26日

rsync 濾掉目錄訊息

伺服器上常用 rsync 去同步程式、但是一堆目錄會讓人看不出來到底同步了哪幾個檔案

在 stackoverflow 上找到了解答、就是用 grep 去過濾輸出的訊息
# rsync -ave ssh 192.168.1.1:/home/abc . | grep -E -v '/$'
receiving file list ... done
abc/def/sohappy.log

sent 5.41K bytes received 162.41K bytes 111.88K bytes/sec
total size is 119.32M speedup is 710.97


但是如果有使用 --delete 參數的話、就要改一下
# rsync -ave ssh --delete 192.168.1.1:/home/abc . | grep -E '^deleting|[^/]$'
receiving file list ... done
abc/def/sohappy.log
deleting abc/jkl/
sent 5.41K bytes received 162.41K bytes 111.88K bytes/sec
total size is 119.32M speedup is 710.97


reference:https://stackoverflow.com/questions/8580873/do-not-show-directories-in-rsync-output

2016年11月18日

rsync 排除多個目錄和檔案

目錄結構

假設把 www 同步到 /home/123 下面、但是排除 B11 資料夾和 A12.123 檔案
把要排除的資料夾和檔案寫在一個檔案內 ex:exclude.list

A01/A12.123
B11


rsync -av --exclude-from=/home/123/exclude.list /home/www /home/123/

重點在於要把www看成根目錄、去寫要排除的資料夾或檔案