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

0 意見:

張貼留言