Rsync Show Progress Bar While Copying Files

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? rsync is free and open source tool. It is useful to copy local or remote file. It reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. You can use any one of the following options to add a total progress indicator when copying files from serverA to serverB or vice versa.

rsync command to with --progress option.

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

rsync command to show progress bar

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

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.

See also

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Your support makes a big difference:

I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft takes a lot of my time and hard work to produce. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. You can donate as little as $1 to support nixCraft:

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:

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.