How to move multiple files with rsync while showing progress?

I can move files with this command:

mv -t /mnt/hdd /home/me/movies/movie1.avi /home/me/movies/movie2.avi

The problem is, that it shows no progress at all, so I don't know if the operation is 1% done or 80% done.

I know that rsync is able to show progress.

So how would an rsync variation of that command above look like, while also showing the progress of the operation?

Thank you

1

3 Answers

You can use the Coreutils Progress Viewer progress Install progress. After installing it1, simply send your mv process to the background and provide progress with its PID:

mv -t /path/to/file1 /path/to/file2 & progress -mp $!

Use progress -w to show a list of all running coreutils processes with their progress. See man progress and its github page for more options and examples.

Further reading with a lot of different approaches:
How can I move files and view the progress (e.g. with a progress bar)?

1: If you’re using Ubuntu 14.04 you’ll unfortunately have to build the software yourself, see the above linked github page.

Background

  • mv is only renaming the link to the inode, when moving a file/directory within the same file system [partition]
  • mv is copying the file/directory and after that removing the original one between file systems [partitions].

In your example, you move to another file system, so rsync will do the same job (copying). You can add a command to remove the original directory tree afterwards (when you are sure that the copying really worked). This can be done in a shellscript (that allows some manual inspection, at least until you feel safe with the operation).

From man rsync

 -P The -P option is equivalent to --partial --progress. Its pur‐ pose is to make it much easier to specify these two options for a long transfer that may be interrupted. There is also a --info=progress2 option that outputs statistics based on the whole transfer, rather than individual files. Use this flag without outputting a filename (e.g. avoid -v or spec‐ ify --info=name0) if you want to see how the transfer is doing without scrolling the screen with a lot of names. (You don’t need to specify the --progress option in order to use --info=progress2.)

Run the same rsync command line again, and if it does not transfer anything, the files are copied and you can remove the original files or directory tree.

Example

Copy with rsync

$ ls -l
totalt 2064196
-rw------- 1 sudodus sudodus 1921843200 apr 26 18:44 orig.iso
-rw-rw-r-- 1 sudodus sudodus 191889408 maj 23 2016 test.iso
$ rsync --info=progress2 -Ha *.iso /tmp 2,113,732,608 100% 171.10MB/s 0:00:11 (xfr#2, to-chk=0/2)

Check (if you wish)

$ rsync --info=progress2 -Ha *.iso /tmp 0 0% 0.00kB/s 0:00:00 (xfr#0, to-chk=0/2)

Remove files and directories with

rm -r *.iso # remove the same as the source in the rsync command line

It would look like:

rsync -aP /home/me/movies/movie1.avi /home/me/movies/movie2.avi /mnt/hdd

Example:

~ rsync -aP /usr/bin/{free,man} /tmp
sending incremental file list
free 18,808 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=1/2)
man 107,008 100% 102.05MB/s 0:00:00 (xfr#2, to-chk=0/2)
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like