Log in

Ever wanted cp with a progress / rate bar?

« previous entry | next entry »
Sep. 25th, 2008 | 03:34 pm

I know I have. Surfing the net turns up a lot of fantastically hacky shell scripts (involving strace no less) to do this. Even then they don't show the kind of info you'd want, like progress so far, transfer rate, and how much longer it's going to take. Why not use rsync? Well rsync has a viscous overhead, particularly when doing disk to disk where the transfer rate is very fast. Why re-invent the wheel though? There already exists a wonderful tool for showing such things on data through pipelines.

Enter pv. pv is simple, overlooked, but vastly cool. Lets take my most recent use of it (and I had to dust off the man page to remember how to use it again) where I wanted to copy a backup image of my laptop from one drive to another.

First I check out the size, and find it's 100g in size. Then I decide that I want to see progress (-p and requires a known size), ETA of transfer (-e), and transfer rate (-r). Then it's just a quick set of pipes away:

$ cat /media/disk/lumos-root.img.orig |pv -s 100g -p -e -r > /media/hdd/backup/lumos.img
[ 25MB/s] [==========> ] 13% ETA 0:54:35

There you have it. Very low overhead tool to show you all the things you'd want to know about your large file transfer. Of course you can do far more complicated things with pv, but hey, at least you don't have to write the pv part yourself!

Link | Share