I want to clone one very large directory (many terabytes of multiple-gigabyte files) into another on another drive. I have been using this command:
ionice -c 3 rsync -avz /path/to/sourcedir/ /path/to/destdir/
The process takes over a day and more often than not gets interrupted, hence the use of rsync
to be able to resume without restarting from zero. The theory should be that the above command is idempotent, so when anything fails I should just be able to reissue the same command to let it work out where it was interrupted and continue from there.
Now, because the point of the operation is to retire and recycle the source drive, before doing that I wanted to be super-sure that all files had been properly copied. So I used the approach in this question to compare each file byte by byte. Sure enough, there were a number of files that had a different hash.
So the theory question: does rsync
, unlike what I thought I understood, work merely on file names, rather than content, or at least length?
And the (more important) practice question: are there other options I could be using instead, to force rsync
to produce an exact clone of the source directory? In particular, in the case in which rsync
is launched when the dest directory already has a file with the same name as one in the source directory, but with different content, I want the command to ensure it is replaced (or "completed") with the actual original file from the source directory.
rscync
works fine. If in doubt simply remove all files in the target directory first. This will make the process take longer but might help you sleep better if you are worried. For an example of cloning see: https://askubuntu.com/questions/1028604/bash-script-to-clone-ubuntu-to-new-partition-for-testing-18-04-lts-upgrade – WinEunuuchs2Unix May 07 '18 at 11:49rsync
should not generate "wrong" files. Are you sure that rsync generated them. Maybe some other program or background service modified those files. Maybe the RAM is flaky (did you check it with memtest from the grub menu?). What files are different? Have you checked manually, what is different between the original file and the copy? Size, some random bytes or are they completely different, like different versions? A couple of years ago I had problems with any copy (cp
andrsync
and ...) via USB in 16.04 LTS, I think caused by some background service. But it worked viatar
. – sudodus May 08 '18 at 05:45rsync
in another computer and afterwards check the md5sums (to check if the problem can affect also other computers). – sudodus May 09 '18 at 10:08