[TriLUG] Copying Files from a Dying HDD...with a twist

Brian via TriLUG trilug at trilug.org
Tue Jul 3 10:01:32 EDT 2018


Hi Gang,

I know there're several choices available to me when it comes to copying 
bunches of files from one place to another (under Linux, if that didn't 
go without saying.. :-) ).  I have a bit of a twist I want to put on it.

The source drive was dropped while it was running, and although it still 
functions, there are now collections of errors in certain areas (my 
guess being correlating to where the heads were when the drive was 
dropped).

What I'd like to do is something that will mirror a directory structure, 
but if a read error is encountered in any given file, that file winds up 
in a different location.  In other words, I want to replicate the 
directory structure in two places; one that gets filled up with 
error-free files, the other that gets filled up with error-containing 
files.  That way I'll have an easy, organized way of seeing what files 
and directories were actually lost/corrupted.  e.g.

/good_files/<original_directory_structure>
/bad_files/<original_directory_structure>

So the question is, is there a command that'll already do this? 
Something like rsync, with an option to give a different target path for 
files when errors occur.  I could always script something, but I feel 
like file-by-file invocations of cp would be much less efficient than 
some command that would handle it internally.

Thanks!
-Brian


More information about the TriLUG mailing list