Search code examples
rsync

Could using -p "-partial" in rsync result in corrupted files?


I'm using a script which runs once an hour to rsync some files. Sometimes the script is interrupted before it completes, e.g. because the client or server shut down.

For most files this is not an issue, as next time the script runs it will copy those.

However, for some large files that take a long time over LAN it may be interrupted before it completes. This means that rsync will have to start from scratch the next time but if it is interrupted again this second time etc then the files will never copy.

I'm therefore thinking of adding the -partial flag as described here: Resuming rsync partial (-P/--partial) on a interrupted transfer https://unix.stackexchange.com/questions/2445/resume-transfer-of-a-single-file-by-rsync

I have tested with "-partial" and it does work, i.e the operation continues from the last transferred file fragment.

My concern is whether this increases the risk of corrupted files? https://lists.samba.org/archive/rsync/2002-August/003526.html https://lists.samba.org/archive/rsync/2002-August/003525.html

Or to put it another way, even if "-partial" does create some corruption, then then next time rsync runs will it find and "correct" those corrupted blocks?

If that's the case then I'm OK to use "-partial" and in the case of any corruption it will simply be corrected the next time?

Thanks.

PS: I don't want to use "-c" as it creates too much hard disk activity.


Solution

  • From the rsync documentation on --checksum:

    Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred, 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.

    So, yes, rsync will correct any partially transferred files, no matter how corrupted they are (in the worst case, all the data will be transferred again).