LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-18-2021, 12:15 PM   #1
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
Verifying physical integrity of backed up files


I bought a new USB drive for primary backups. I used 'rsync -av src dest', and all appears to have copied over.

I want to verify the backup files are actually stored correctly (no on-disk errors), and are exactly the same as the source.

Searches bring up rsync -c or --checksum. But diving into it, this function only works on the sending and receiving processes, not the files after they have been written to disk.

How can I verify the checksums of all my backup files against my source files, post write to disk?
 
Old 06-18-2021, 02:23 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,376

Rep: Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336
Code:
rsync -avc src dest
where src must be the canonical file version. Unless your media is dodgy or you saw errors, your files are good. But go ahead if you want to check.
 
Old 06-18-2021, 03:04 PM   #3
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,150

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Put the following script named diff12.sh in a directory in your path:

Code:
#!/bin/bash
src=$1
dest=$DESTPATH${src#$SRCPATH}
cmp $src $dest
then set the directories of the source and dest and compare each file in src to see if dest matches.

Code:
export SRCPATH=src 
export DESTPATH=dest 
find $SRCPATH -type f diff12.sh {} \;
 
Old 06-18-2021, 07:03 PM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by SlowCoder View Post
How can I verify the checksums of all my backup files against my source files, post write to disk?
A cheap-n-dirty scriptable post-backup process could be used. You'd need to make a list of the files on the backup drive and obtain their checksums (md5sum or better), sort the result and save the results in a file ("backup.cksums"). Do the same for the source device/filesystem/tree ("source.cksums"). A check for files that are different in the two collections of files would be to issue:
Code:
$ cat *.cksums | awk '{print $1}' | sort | uniq -c > freq.lis
$ grep ' 1 ' freq.lis
You want the vast majority of the checksums that result from the above steps to be found in pairs (or more which means you have identical copies sitting in different subdirectories). Ideally, there are the same number of files in the source and the backup "trees" and the checksums are identical across the trees so everything in "freq.lis" will be prefixed with "2"---perfect backup! If anything results from the "grep ' 1 '", issue "grep some-checksum" against each of the ".cksums' files to find out what files differed.

HTH...
 
Old 06-19-2021, 02:08 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by SlowCoder View Post
Searches bring up rsync -c or --checksum. But diving into it, this function only works on the sending and receiving processes, not the files after they have been written to disk.
I take it your delving didn't include the manpage.
Quote:
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.
 
Old 06-20-2021, 12:39 PM   #6
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Original Poster
Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by business_kid View Post
Code:
rsync -avc src dest
where src must be the canonical file version. Unless your media is dodgy or you saw errors, your files are good. But go ahead if you want to check.
Quote:
Originally Posted by syg00 View Post
I take it your delving didn't include the manpage.
Yes, I did.

To answer both quotes: Apparently this is only an ack with checksum between the sender and receiver protocols, and does not verify the physical write to hardware (hdd, ssd, etc.)
 
Old 06-20-2021, 02:28 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by SlowCoder View Post
Apparently this is only an ack with checksum between the sender and receiver protocols, and does not verify the physical write to hardware (hdd, ssd, etc.)
Where are you getting this information?
 
Old 06-20-2021, 02:39 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by SlowCoder View Post
Apparently this is only an ack with checksum between the sender and receiver protocols, and does not verify the physical write to hardware (hdd, ssd, etc.)
Assuming that to be true and to mean what you think (I don't know), then the simplest way that comes immediately to mind would be to simply run your rsync command a second time after the initial backup and see if it finds anything different.
 
Old 06-21-2021, 06:56 AM   #9
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,376

Rep: Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336Reputation: 2336
@OP: If you use the -c option and run rsync a second time like I told you back in post #2(!) calculating the checksum checks the write. Is there a difficulty with that?
 
Old 06-21-2021, 10:42 AM   #10
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Original Poster
Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by astrogeek View Post
Assuming that to be true and to mean what you think (I don't know), then the simplest way that comes immediately to mind would be to simply run your rsync command a second time after the initial backup and see if it finds anything different.
Quote:
Originally Posted by business_kid View Post
@OP: If you use the -c option and run rsync a second time like I told you back in post #2(!) calculating the checksum checks the write. Is there a difficulty with that?
Now, this does make sense! I would just need to 'sync' the cached data in between to ensure the data has been written.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Verifying integrity of a CD/DVD burned from a ISO the_gripmaster LinuxAnswers Discussion 3 09-14-2014 10:45 AM
verifying the integrity of a file incomingid Linux - Newbie 3 10-24-2008 09:05 PM
Verifying archive integrity...tail: cannot open `+6' for reading vamseekrishna Linux - Software 3 10-05-2007 05:41 AM
Verifying drive integrity jdhar Linux - Software 7 09-22-2005 09:28 AM
re: verifying integrity of downloaded rh9 rpms ergo_sum Linux - Newbie 2 12-19-2003 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration