LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-25-2006, 03:45 AM   #1
carl0ski
Member
 
Registered: Sep 2004
Location: Melbourne, Victoria Australia
Distribution: Support those that support you :)
Posts: 872
Blog Entries: 12

Rep: Reputation: 30
verify successful cp like xcopy does in windows?


What routine will best verify that a very large quatity of files copy correctly to a new disk?

preferably bash command
 
Old 10-25-2006, 06:03 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
The regular cp command will print an error message on the standard error file handle and set the $? environment variable to non-0 if an error was encountered while copying.

If you want to keep a log of errors during a large copy, you can re-direct the standard error messages to a file. For example, with this large recursive copy command, we send any error messages to cp_errors, and send a mail containing those errors if there were problems:

Code:
cp -R /var /mnt/backup 2> cp_errors
if [ $? -ne 0 ]; then
  cat cp_errors | mailx -s "copy errors" my@email.address
fi
You can also do a similar thing like this, which is a little easier to do from the command line:

Code:
cp -R /var /mnt/backup 2> cp_errors || \
    echo "You got errors - see cp_errors"
 
Old 11-03-2006, 03:14 PM   #3
j88pers
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Rep: Reputation: 0
verify copy?

I use md5sum. It generates a checksum against the file & can compare that against the written file.

something like this:

Code:
find /path_to_files | while read in; do
  md5sum "$in" >> /tmp/copy.md5
done
>>do the copy<<

this writes the md5 checksums to a text file for later verification. You could also use just sum as it's quicker. (but it may not offer the compare to file - man sum)

Then to verify I just use md5sum again on the target directory:

Code:
cd /target directory
md5sum -c /tmp/copy.md5
as others said, you can redirect std out and std error to files for your own comfort.
Code:
md5sum -c /tmp/copy.md5 &> /tmp/crc.out
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xcopy functionality with linux? syssyphus Linux - General 12 11-27-2005 01:24 PM
dos xcopy to backup changes to samba susewho Linux - Software 1 02-01-2005 07:36 AM
What windows VMware 4 network settings were successful for forwarding your connection Armoredcav4 Linux - Software 3 11-02-2003 12:36 PM
Verify Linux is successfully joined Windows AD Charlotte Linux - General 0 09-17-2003 08:14 PM
Print to Windows - failed jobs vanish as if successful. Izzard Linux - Networking 0 08-20-2003 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:07 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