1

Safecopy can rescue a file or a partition from a failing hard drive. But what if you want to rescue a whole directory? It doesn't look like there's a way to do this in safecopy.

Is there a command that will run safecopy, recusrively, on every individual file in a directory, and put it in the appropriate place on the rescued media?

I have a huge, failing drive but I only need to rescue one directory from it.

3x5
  • 111
  • 2
  • That can be easily done. But you should provide an example directory structure with the necessary command lines for Safecopy because I am not familiar with it (as probably others, too) and don't want to have to learn first how this program works. – Hauke Laging Aug 28 '17 at 21:03
  • OK, to rescue a file from a damaged hard drive with safecopy, you run this command: safecopy /path/to/problemfile ~/saved-file. In my case, the folder would be media/brokendrive/Users/bill/Documents/ and I would be rescuing to /media/newdrive/billrescue/. In the old drive are folders like /photos, /contracts, and so on. I would want the structure to be the same on the new drive. – 3x5 Aug 29 '17 at 15:17
  • Why wouldn't you use this tool to recover an entire filesystem partition from the bad hard drive to a working medium, and then get the individual files and directories from the recovery? – Kaz Aug 29 '17 at 19:29

1 Answers1

0

I don't know whether Safecopy creates the missing directories in the target path thus we create them first:

cd /media/newdrive/billrescue
find /media/brokendrive/Users/bill/Documents -type d -printf "%P\0" |
    xargs -0 echo mkdir -p

Now we call safecopy once for every file:

cd media/brokendrive/Users/bill/Documents
find . -type f -exec echo safecopy {} /media/newdrive/billrescue/{} \; | head

Remove the echo and the | head if the output is what you need.

Or:

find /media/brokendrive/Users/bill/Documents -type f -printf "%P\0" |
    xargs -0 -I{} echo safecopy /media/brokendrive/Users/bill/Documents/{} /media/newdrive/billrescue/{}
Hauke Laging
  • 88,146
  • 18
  • 125
  • 174