Home | Scripts | Demo | About | Links

script: cpverify (download)
purpose: verify that copied or burned files have been written error free
requires: standard GNU commands, md5sum
version: 1.3
usage: cpverify [-hml] -d <source_dir> <copy_dir> | -s <source_file> -c <copy_file>
     -s <source_file>, source file location
     -c <copy_file>, copied file location
     -d <source_dir> <copy_dir>, paths to the source and copy dirs
     -h, usage and options (this help)
     -m, manual
     -l, see this script"


    cpverify verifies that a file or directory structure has been copied or
    burned without errors. That is, the copied file(s) is exactly the same
    as the original. This is done by calculating a cryptographic checksum
    using the md5 message-digest algorithm on each file from the source and
    the copy destination. The checksums for each file are then compared. Any
    difference indicates that the copied file is not the same as the
    original source file. Name of the file that fail to match the original
    source file is printed to stdo.

    Initially this script was written to verify that a CD ROM backup has
    been burned error free. Currently the script can verify whole
    directory trees as well as single files.


    To verify that a file ~/dev/src.tar.bz2 is the same as ~/backup/src.tar.bz2

        $ cpverify -s ~/dev/src.tar.bz2 -c ~/backup/src.tar.bz2

    To verify that dir structure ~/backup have been burned correctly to
    the /mnt/cdrom

        $ cpverify -d ~/backup /mnt/cdrom

    To verify that two CD ROMS are identical, where the mounting points are
    /mnt/cdrom and  /mnt/cdrom2

        $ cpverify -d /mnt/cdrom /mnt/cdrom2


    In August 2004 a collision has been found in MD5 and other hash functions.
    This means that it is possible to find two messages with the same hash, but
    the attacker can't determine what the hash will be. Immediate implications of
    this depend on how and where MD5 is used. I can only advise to learn about
    this issue and judge whether it is safe to keep on using MD5 until it will
    get replaced by a safer alternative.