Re: cp with verify?




Michael Tosch wrote:
RolandRB wrote:
When I was using MS DOS I could specify a "verify" option with the copy
so that it would read back in the block it had written and verify that
the checksum was the same as the block it just copied and if the
checksum differed it would rewrite the block (at least I believe it
worked that way). Now I am working on various Linux and Unix flavors
(AIX 5.2 currently) where file integrity is extremely important and I
am wondering what facilities exist for both administrators and
end-users to do a "verify" on the file or batches of files copied. I
know about the "sum" command but don't have a script that can handle
doing the checksum and retrying if it fails using the usual parameters
given to "cp". Can somebody point me to a web site that covers this
issue of verified copies?

Thanks,
Roland


cmp compares two files.
To do a comparison after a successful cp:

cp "$file" "$dest" && cmp "$file" "$dest" || echo "failed"

That's a good idea. Thanks! The files are likely to be circa 1 Gbyte
binary files and "cmp" will work on binary files and it would be a more
thorough check but I am wordering about the speed of it compared to
doing a less thorough "sum" checksum. Most likely a number of files of
this size will be copied across in bulk.

But if you trust the Unix kernel and the hardware then you can
just check cp's exit status:

cp "$file" "$dest" || echo "failed".

I am wondering if it is possible for "cp" to return a zero return code
but the copy not to be a perfect copy.


--
Michael Tosch @ hp : com

.



Relevant Pages

  • Re: IOMEGA Rev intermittent failures
    ... I have the few remainging sites I do work for running BackupEdge ... The check-sum verify is the second option ... Lone-Tar calculates and adds a checksum only on the 512 byte file ... correction built into tape drives, you need to put something else into the ...
    (comp.unix.sco.misc)
  • Re: compare two directory trees
    ... There are two ways to verify if the CD/DVD burning is correct. ... then verifying the checksum later. ... is not simply an MD5 of the entire ISO; it checksums the data inside a ... Compare the two images byte-by-byte using something like ...
    (Debian-User)
  • Re: cp with verify?
    ... checksum differed it would rewrite the block (at least I believe it ... end-users to do a "verify" on the file or batches of files copied. ... to disk, cmp's reads will probably not ask the system to read ... cache, and even if the data is not corrupted on disk at this ...
    (comp.unix.admin)
  • Re: cvsup and security
    ... >>> checksum to verify that the download is legit and not corrupt. ... >>> the ports collection update that I'm receiving through cvsup is legit ...
    (FreeBSD-Security)
  • Re: cp with verify?
    ... checksum differed it would rewrite the block (at least I believe it ... end-users to do a "verify" on the file or batches of files copied. ... to disk, cmp's reads will probably not ask the system to read ... cache, and even if the data is not corrupted on disk at this ...
    (comp.unix.admin)