Good afternoon,

I am using Ubuntu 12.04 as a repo and would like to view a progress bar when using rsync from the command line. I tried the option from http://www.cyberciti.biz/faq/show-progress-during-file-transfer/ (-P) but I prefer to see a progress bar and not using Grsync. I understand this may not be easy but I am paid hourly so its fine by me. I am using "rsync -P source dest" currently.

share|improve this question
    
Have you read this? stackoverflow.com/questions/238073/… – A.B. Apr 14 '15 at 19:16
    
I appreciate the fast response. I look forward to researching this. – Joseph Smith Apr 14 '15 at 19:26
    
That was a good start but I need to know how to make the progress bar update as rsync is working. A friend said that I need to implement the server size and implement a watch command with pipe. – Joseph Smith Apr 14 '15 at 19:55
    
There is an answer :) – A.B. Apr 16 '15 at 5:44
up vote 5 down vote accepted

How about this?

rsync_param="-av"
rsync "$rsync_param" a/ b |\
     pv -lep -s $(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)
  • $rsync_param

    Avoids double input of parameters

  • $(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)

    Determines the number of steps to complete.

  • a/ b

    1. a/ is the source
    2. b is the target
share|improve this answer
1  
@JosephSmith Were you satisfied with my answer? Then give me a upvote (∧). If I could solve your problem, then it would be nice if you'd mark my answer (✓). ;) – A.B. Apr 18 '15 at 14:52
    
I accepted this a couple days ago with a big smile. I just un selected and accepted it again though. I do not think I can up vote because I do not have enough credit. Thanks for the assistance btw. – Joseph Smith Apr 21 '15 at 12:53
    
Any ideas why I get an error, no file or directory found? The command I run is: root@cto:/repo/ubuntu# rsync "$rsync_param" -a --prune-empty-dirs --exclude "*.iso" archive.ubuntu.com/ubuntu/indices/ /repo/ubuntu/indices | pv -lep -s $(rsync "$rsync_param"n archive.ubuntu.com/indices/ /repo/ubuntu/indices | awk 'NF' | wc -l) – Joseph Smith Apr 28 '15 at 12:20
    
"$rsync_param"n is rather strange; the quotes mean it can only work on options with no spaces, and attaching the n to the end means it can only work with short options. Much clearer and easier is simply $rsync_param -n, which specifies dry-run without relying on the format of rsync_param, and by not quoting it, long options could be included as well – Izkata Nov 18 '16 at 5:24
    
Worked first time, except noticed it doesn’t displays transfer rate – Ciasto piekarz Nov 4 '17 at 16:28

rsync has a --info option that can be used to not only output the current progress, but also the transfer rate and elapsed time:

--info=FLAGS            fine-grained informational verbosity

The explanation of how to use it comes under the -P option in the man page:

-P     The -P option is equivalent to --partial --progress.  Its purpose is to
       make it much easier to specify these two options for a long transfer that
       may be interrupted.

       There is also a --info=progress2 option that outputs statistics based on
       the whole transfer, rather than individual files.  Use this flag
       without  out‐putting  a  filename  (e.g. avoid -v or specify --info=name0)
       if you want to see how the transfer is doing without scrolling the screen 
       with  a  lot  of names.   (You  don’t  need  to specify the --progress
       option in order to use --info=progress2.)

So the following:

rsync -r --info=progress2 --info=name0 "$src" "$dst"

Results in the following being output and continuously updated:

18,757,542,664 100%   65.70MB/s    0:04:32 (xfr#1389, to-chk=0/1510)

Note that when the transfer starts the total number of chunks, and therefore the current progress, can change when the recursive option is used as more files are discovered for syncing

share|improve this answer

This finally worked:

rsync "$rsync_param" -a --prune-empty-dirs --exclude "*.iso" rsync://archive.ubuntu.com/ubuntu/indices/ /repo/ubuntu/indices | pv -lep -s $(rsync "$rsync_param"n rsync://archive.ubuntu.com/indices/ /repo/ubuntu/indices | awk 'NF' | wc -l)
share|improve this answer

You can use --progress and --stats parameters.

rsync -avzh --progress --stats root@server:/path/to/file output_name

root@server's password: 
receiving incremental file list
file
         98.19M  54%    8.99MB/s    0:00:08
share|improve this answer

If your version of rsync does not accept the --info=progress2 option, you can use tqdm:

To install:

pip install tqdm

To use:

$ rsync -av /source /dest | tqdm --unit_scale | wc -l
10.0Mit [00:02, 3.58Mit/s]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.