Ubuntu – Does rsync verify file copies on local drives

backupdata-corruptionfilesystemrsync

I use rsync to do incremental backup of the local ext3 HD in my laptop onto an ext4 HD connected through USB to the laptop. I assume that rsync treats both these HDs as local, so I'm wondering if rsync performs any kind of verification of the files copied.

Looking at the man page it seems that it does ("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."), but this is contradicted on StackExchange. So I'm wondering do I need to do the verification myself? And if so, should I use diff or rsync -c after the actual execution of rsync?

As far as I understand the verification performed by rsync is only a verification of the transfer of the file, not the writing of the file to disk. Verification of the writing of the file to disk is, as far as I can find out, left up to the underlying driver/file system. Is this safe enough? Is ext4 capable of detecting and warning if a write went wrong? And will rsync report it?

Since this is more a questions of data verification and possible data corruption I have inserted a couple of more tags, to help my post be read by the right people. I also tried to expand a bit on the question itself.

Best Answer

  • Is this safe enough?

    I would assume yes. If you want rsync to do a check you need to run rsync -c after copying so you can have some extra verification using rsync. Or use a md5sum on the files.

    Is ext4 capable of detecting and warning if a write went wrong?

    Yes. We are talking about drivers and the filesystem so an error any of these will result in an exit code. Of course there is a worst case scenario here: if the driver/filesystem is faulty the exit code could be wrongly sent as correct. I would not assume this to be correct myself and use a tool like md5sum to check the results myself.

    And will rsync report it?

    As soon as the receiving end errors out so will rsync.

  • Related Question