LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2007, 08:59 AM   #1
leemoreau
Member
 
Registered: Jan 2004
Posts: 48

Rep: Reputation: 15
Command to copy files/folders but skip bad/corrupt files??


Hey everyone,

I have a harddrive that's failing. I can only access the command line and I need to backup everything to my USB hard drive. Problem is some files are corrupt, so I'm doing cp - R /source /destination but as soon as it hits a bad file, it says file not found, or some sort of error and stops. Is there any way at all that I can tell it to copy a folder and all it's sub folders, and if it hits a bad file, just keep on going and skip it? Would make it so much easier.. thanks!
 
Old 04-02-2007, 12:14 PM   #2
LuLoh
LQ Newbie
 
Registered: Feb 2007
Location: Spain
Distribution: debian etch
Posts: 13

Rep: Reputation: 0
I had a similar problem and I could not remove the files because the stat failed. A fsck solved the problem.
It can happen that you loose some information when you perform a fsck. but you can run it first with the -N option to see what would happen.
I don't know how to automatically skip the corrupt files, I guess the dd command could help for a more low-level copy, skipping the filesystem problems (in fact, it has a noerror option), but I don't know exactly what options you should use. Check out this site if you want to try:
http://www.cyberciti.biz/tips/repair...eiserfsck.html
where this low-level copy command with dd is, for example:
# dd if=/dev/sda of=/dev/sdb conv=noerror
And, as I read there, there's another tool called ddrescue! Fine!
http://www.cyberciti.biz/tips/how-do...e-command.html

Tell us if it helps.
 
Old 04-02-2007, 02:27 PM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
You can create a tar archive and exclude files from the archive.
I've used it to exclude complete directories, but my understanding of the man pages is that the -X option might be what you need.
 
  


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
rsync syntax to skip directory, but copy select files.. tnicol Linux - Software 3 07-24-2007 05:40 AM
script or utility to copy files and folders m2azer Linux - General 1 12-22-2005 10:09 AM
Software to repair corrupt or bad jpeg/gif files? blkcamarozr28 Linux - Software 3 11-13-2005 11:48 PM
copy files and folders codepoet Linux - Newbie 2 06-12-2005 02:08 PM
how to copy files/folders??? Gallienus Linux - General 4 12-15-2003 12:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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