0

I ran rsync with the --stats option, because the sync is being done over the metered connection. However, after some time I wanted to get some idea of how much had been transferred and then (potentially, depending on the results) restart the sync. But when I hit Control+C it stopped the sync but did not give me any stats, which thwarted my whole intention for using --stats.

I looked at the man page but didn't see any obvious way to get statistics on how much data is transferred in the case of an interrupt, which was not mentioned. Is there some way to get statistics on cumulative data transferred which does not rely on the transfer fully completing, or doing a lot of manual arithemtic and estimation?

The command I am running looks something like this:

rsync --stats -Ppa $REMOTE:'/path/to/sync' /local/path/destination
2
  • Is rsync running via ssh? Could you please provide the actual command?
    – Binarus
    Commented Sep 12, 2020 at 8:36
  • @Binarus done..
    – Michael
    Commented Sep 12, 2020 at 15:30

1 Answer 1

1

Unfortunately, I cannot test at the moment. However:

Since your problem occurs when you interrupt rsync, the natural remedy would be a live display of the progress, i.e. to let rsync show the progress while it does its thing. Two approaches to this come to my mind:

rsync has the --info= option. To get an idea what you can do with it, execute rsync --info=help; this will list the flags you can append at the right side. Those flags can have a number appended which designates how verbose the information should be. For example, you could add --info=progress2 or --info=progress3 to your command. Please note that (as I can't test at the moment) I don't know whether it is possible to monitor the whole data transfer size that way (progress seems to relate more to individual files), but IMHO, chances are good.

You should consider using --no-inc-recursive as well, because this makes rsync scan first. That way, it knows what to do before starting the actual work, which is the only method to get figures in progress monitoring correct. Otherwise, rsync would scan while working which could lead to the progress info always telling "90%" ...

Another approach would be to use pv. Basically, you can use pv in a pipe between two processes and let it monitor and output the amount of data transferred, and other information, depending on the command line options. A basic usage of pv in conjunction with rsync is described here.

However, that example takes the number of files for progress calculation; you need to give the number of files in pv's command line, which is ugly. But again, you can remedy this by letting rsync count the number of files before and then start the actual command, giving the result to pv (instead of a hard-coded number). I am not sure, but I believe that it also should be possible to let pv count the total amount of data.

Good luck!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .