Check integrity of file / folder transfer - recursive md5sum checksums

How to check that directories of copied files retain their integrity on linux. I use this command to check my photographs from my digital SLR SD / CF cards retain their integrity when copied to my PC. Read on... 



1. Change directory into the parent source directory and run the following command which recursively checks the source directories and files, and creates a file containing md5 checksum hashes of the source files:

find ./ -type f -print0 | xargs -0 md5sum > ./checksums.md5

2. Copy the checksum file to the destination parent directory

3. Change directory into the destination parent directory

4. Run the following command that checks the precompiled md5 checksum hashes to the destination files. This assumes the destination and source directory have the same directory hierarchy:

 md5sum -c checksums.md5

Each file is checked and a status reported. At the end the script will report the overall success of the recursive checksum exercise. Any files that fail the checksum will need to be recopied / transferred. 

Note: The checksum file will fail it's md5 hash as it wasn't included in the original source md5 recursive hashing operation.

No comments:

Post a Comment