0

I'm using rsync to push some changes to a server, for that I made a bash script and I want to show a status notification in the desktop (I'm using Linux Mint 18 Cinnamon)

Is it possible to send the output of rsync to notify-send so I can see the amount of data synchronized? Here is my actual bash script:

notify-send "sincronizando esteticas"
rsync -tprvkku --exclude "00_docs" --exclude "temp" --exclude "config.php" --progress public_html/ rsync://myserver:/myfiles 
notify-send "sincronizacion terminada"
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
Chico3001
  • 135

1 Answers1

1

If you want a notify popup holding the final summary line, something like

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

then you can capture the rsync output into a file, and use the last 2 lines of the file:

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

If you would like a more detailed summary, add --info=stats2

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

This will provide extra info such as:

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
meuh
  • 51,383