Rsync Show Progress Bar While Copying Files

by on January 12, 2010 · 6 comments· LAST UPDATED October 16, 2013

in , ,

I am a new Unix user. I am using rsync to upload and download a large size files. Is there a way to display the progress bar for file? How do I show progress while copying files using rsync locally or remotely on Linux or Unix like operating systems?

Short answer - you can't. But you can use any one of the following options to add a total progress indicator:

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Estimated completion time5m
a] rsync command to with --progress option.

b] pv command - monitor the progress of data or data transfer through a pipe. This is a recommend option for most users.

rsync command

You need to use the --progress or -P option which show progress during file transfer. The syntax is as follows:

 
rsync --progress source dest
rsync -P source dest
rsync [options] --progress source dest
rsync -av --progress /path/to/*.mp3 /nfs
rsync -av --progress /path/to/*.avi -e user@remote.example.com:/data
###############################################################
## The following only works with the latest version of rsync ##
###############################################################
rsync -av --info=progress2 source dest
rsync -av --info=progress2 /path/to/*.avi -e user@remote.example.com:/data
 
## See the pv command below for more info & syntax ##
 

Examples

To copy file from /foo/*.tar.gz to a remote server called server1.cyberciti.biz, enter:

 
rsync -av -P /foo/*.tar.gz nixcraft@server1.cyberciti.biz:~
 

OR

 
rsync -av --progress /foo/*.tar.gz nixcraft@server1.cyberciti.biz:~
 

In this example, copy files from a remote server:

 
rsync -av --progress root@nas01:/tmp/*Office* .
 

Sample outputs:

receiving file list ...
2 files to consider
MacOffice2011wSP2_English.dmg
  1036923510 100%   14.72MB/s    0:01:07 (xfer#1, to-check=1/2)
Office Mac Home and Student 2011 - 1PC-1User Keys.html
        2230 100%   23.67kB/s    0:00:00 (xfer#2, to-check=0/2)
sent 64 bytes  received 1037052576 bytes  15363742.81 bytes/sec
total size is 1036925740  speedup is 1.00

The --info=progress2 option shows statistics based on the whole transfer, rather than individual files. Use this flag without outputting 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.

 
rsync -av --info=progress2 root@nas01:/tmp/*Office* .
 

Sample outputs:

sending incremental file list
MacOffice2011wSP2_English.dmg
  1,036,923,510  99%   39.90MB/s    0:00:24 (xfr#1, to-chk=0/2)
sent 1,037,176,846 bytes  received 35 bytes  40,673,603.18 bytes/sec
total size is 1,036,925,740  speedup is 1.00

Use pv command to monitor progress of rsync command

The pv command allows you to see the progress of data through a pipeline. It provides the following info:

  1. Time elapsed
  2. Percentage completed (with progress bar)
  3. Current throughput rate
  4. Total data transferred
  5. ETA

The syntax is:

 
rsync options source dest | pv -lpes Number-Of-Files
 

So if you have 42 files in /tmp/software and you would like to copy them to /nas10, enter:

 
rsync -vrltD --stats --human-readable /tmp/software /nas10 | pv -lep -s 42
 

OR

 
rsync -vrltD --stats --human-readable /tmp/software /nas10 | pv -lep -s 42 >/dev/null
 

Sample outputs:

Animated gif 01: rsync and pv command demo

Animated gif 01: rsync and pv command demo

See also
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 6 comments… read them below or add one }

1 Bart van Bragt May 17, 2011 at 8:09 am

Also add -h to show human readable sizes (350M instead of 367071842).

Reply

2 reply September 4, 2012 at 9:35 pm

um… That’s not a progress bar. That’s progress output.

Reply

3 MattH October 16, 2013 at 2:51 am

--progress is what you are looking for. (incase anyone gets this in a google search like i did)

rsync -zru --update --progress /path/to/source /path/to/dest

Reply

4 Dana March 14, 2014 at 2:05 am

Thanks for the informative post.

If you are running an “update” to a large folder you may not know how many files will be updated in advance, thus making it difficult to supply the file count to PV without doing an rsync –dry-run first. You can capture the “update” file count into a variable like this:

FCNT=$(rsync -r --dry-run --ignore-existing --stats --human-readable -e ssh username@192.168.1.40:/home/username/Videos/ ./ | grep -E 'Number of files transferred: ([0-9]+)' | grep -o -E '[0-9]+'); let FCNT+=5

Then you can call rsync and pv with a reference to the file count variable:

rsync -rav --ignore-existing -e ssh username@192.168.1.40:/home/username/Videos/ ./ | pv -pteabl -s $FCNT >/dev/null

A few items to note:

  • The file count variable ($FCNT) has an extra five files added. Why is that? The rsync output from your file xfer will have four lines at the end of the files transferred list as a summary; pv will count those four lines as 5 lines. By adding the 5 lines in advance we’ll prevent our progress bar from going over %100 (by much).
  • The pv parameters I used are slightly different. I like pv -pteabl because it gives me a files-sent-count, time-elapsed, and average throughput on the progress bar.
  • Using the pv -l argument converts the -b parameter from bytes sent to a file count, and converts -s from size of bytes sent to number of lines processed.
  • Your second call to rsync (the one that sends the files) needs to have the -v parameter to list one line per file processed otherwise the pv command will stay at 0%. Similarly if you use -vv or -vvv on the rsync call then pv will receive a much larger number of “files” than predicted.
  • Using the rsync -v switch will cause rsync to list folders it is entering as another line, i.e. another file processed from the pv perspective. In short, if you are processing more than one sub folder with your rsync command the file count passed to pv will be slightly inaccurate.

Reply

5 Nilesh Govindrajan June 21, 2014 at 3:00 am

–info=progress2 seems to be available only on 3.1.0+
I was using 3.0.9 and it complained no such option exists

Reply

6 paolo September 4, 2014 at 2:52 pm

Leave a Comment

Tagged as: , , , , , ,

Previous Faq:

Next Faq: