bash: inform-send를 사용하여 rsync 상태 보내기

bash: inform-send를 사용하여 rsync 상태 보내기

저는 rsync몇 가지 변경 사항을 서버에 푸시하는 데 사용하고 있습니다. 이를 위해 bash 스크립트를 만들었고 데스크탑에 상태 알림을 표시하고 싶습니다(Linux Mint 18 Cinnamon을 사용하고 있습니다).

동기화되는 데이터의 양을 확인할 수 있도록 출력 rsync을 보낼 수 있습니까 ? notify-send이것은 내 실제 bash 스크립트입니다.

notify-send "sincronizando esteticas"
rsync -tprvkku --exclude "00_docs" --exclude "temp" --exclude "config.php" --progress public_html/ rsync://myserver:/myfiles 
notify-send "sincronizacion terminada"

답변1

마지막 요약 줄을 유지하기 위해 알림 팝업을 원하는 경우(예:

sent 6,673,231 bytes  received 17,718 bytes  13,381,898.00 bytes/sec
total size is 6,613,892  speedup is 0.99

그런 다음 rsync 출력을 파일로 캡처하고 파일의 마지막 두 줄을 사용할 수 있습니다.

rsync ... | tee /tmp/out
notify-send "$(tail -2 /tmp/out)"

좀 더 자세한 요약을 원하시면 추가하세요--info=stats2

rsync --info=stats2 ... | tee /tmp/out
notify-send "$(tail -16 /tmp/out)"

그러면 다음과 같은 추가 정보가 제공됩니다.

Number of files: 932 (reg: 929, dir: 2, link: 1)
Number of created files: 932 (reg: 929, dir: 2, link: 1)
Number of deleted files: 0
Number of regular files transferred: 929
Total file size: 6,613,892 bytes
Total transferred file size: 6,613,888 bytes
Literal data: 6,613,888 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 6,673,231
Total bytes received: 17,686

관련 정보