When using rsync sometimes the rsync doesn't copy all the files done, below is my code I use. Is they a way to do a checksum or check after the rsync to see if all the files have been copied and if not try again until all files have been copied?
TEMP="/home/user/temp"
OPTS="-rav -h"
rsync $OPTS --stats [email protected]:/home/user/Local $TEMP
As hinted at by uʍop ǝpısdn's answer, rsync -c
or rsync --checksum
may do what you need.
-c, --checksum: skip based on checksum, not mod-time & size
This forces the sender to checksum every regular file using a 128-bit MD4 checksum. It does this during the initial file-system scan as it builds the list of all available files. The receiver then checksums its version of each file (if it exists and it has the same size as its sender-side counterpart) in order to decide which files need to be updated: files with either a changed size or a changed checksum are selected for transfer. Since this whole-file checksumming of all files on both sides of the connection occurs in addition to the automatic checksum verifications that occur during a file's transfer, this option can be quite slow.
Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking its whole-file checksum, but that automatic after-the-transfer verification has nothing to do with this option's before-the-transfer "Does this file need to be updated?" check.
The concerns about this being slow are probably not relevant these days, and this seems to be a good option when you can't or don't want to rely on modification times.