Copying Files & Directories in Linux with Progress Indication

Copying Files & Directories in Linux with Progress Indication

I’ve long used rsync for high fidelity, detailed copies of large swathes of files in Linux. For example:

rsync -av --progress /source/directory /destination/directory

This gives you really nice, file-by-file progress indications — which is especially useful when moving large files across the network between machines or even locally across physical devices.

Today I was moving data from old hard drives and just wanted overall progress on the total job to be done. rsync still FTW!

rsync -a --info=progress2 /source/directory /destination/directory/

NB — do not use a trailling / in the source directory if you want the copied files to be retained inside of that directory name in the destination!

This provides lovely summary output like this:

ubuntu@ubuntu:/media/ubuntu$ rsync -a --info=progress2 /source/directory /destination/directory
  2,675,525,167  71%   13.49MB/s    0:03:09 (xfr#1281, to-chk=0/1712)  

A Better, More Robust Way to Do This

Running this command gets some extra good stuffs.

rsync -a --info=progress2 --checksum --partial /source/directory /destination/directory/

Explanation of the Additions:

  1. -checksum:
    • Ensures that files are compared using checksums rather than just timestamps and file sizes.
    • Guarantees that files are transferred only if their content differs, even if metadata like modification times are identical.
  2. -partial:
    • Retains partially transferred files if the transfer is interrupted, allowing resumption without starting over.

links