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 出力をファイルとしてキャプチャし、ファイルの最後の 2 行を使用できます。

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

おすすめ記事