Here are some commands to copy directories with progress information.
If there are many small files:
cp -av sourcedir targetdir | pv -l -s filecount > logfile
This will report progress based on number of files that are copied.
You can redirect to /dev/null
if you don't need logfile
.
Use the following command to get filecount
:
find sourcedir | wc -l
If there are few huge files:
tar c sourcedir | pv -s size | tar x -C targetdir
This will report progress based on bytes that are copied.
targetdir
must exist.
Use the following command to get size
:
du -sh sourcedir
If you want to use rsync:
rsync -ai sourcedir/ targetdir/ | pv -l -s filecount > logfile
Get filecount
as shown above.
If you are copying on the same system then rsync -a
is practically the same as cp -a
. The advantages of rsync is when you are copying over the network or if you are updating (or comparing) a previous copy.
See here for more details: