LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command to copy files/folders but skip bad/corrupt files?? (http://www.linuxquestions.org/questions/linux-newbie-8/command-to-copy-files-folders-but-skip-bad-corrupt-files-542643/)

leemoreau 04-02-2007 08:59 AM

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!

LuLoh 04-02-2007 12:14 PM

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.

Wim Sturkenboom 04-02-2007 02:27 PM

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.


All times are GMT -5. The time now is 03:40 AM.