Using DDrescue to Backup Local Disk on Corrupted vBox VDI

After some crafty, -guessing-, I finally got this command to create a local .img of a remote disk (vbox) that is failing.

It work, -slowly-, but it works:

ssh root@example  ddrescue -d /dev/sda1 - | pv | cat > /home/user/path/to/tester1.img | cat > /home/user/path/to/tester1.logfile

My question is about the "| cat > /home/user/path/to/tester1.logfile " portion of the command...

Clearly this will take hours and put strain on the disk, however I don't want to wait the entire time then discover that there isn't a logfile that I can check.

Can someone with better unix skills than me, verify logfile portion of my command or provide a better solution?

thx

Solution:
Big thanks (and apologies) to @davidgo

I eventually used this to get save my data from a failing .vdi disk:

#ddrescue -d /dev/sda /media/sf_shared_folder/tester1.iso /media/sf_shared_foldertester-dd.log

with his original solution, I didn't see the change in direction of ssh from "localhost to remote", "remote to local", which caused some confusion.. Additionally, when I tried the sshfs -C user@targetmachine:/home/user/path/to /m2 I ended up with a ssh error "connection reset by peer".


Solution 1:

I very much doubt that command is doing what you are attempting. Have you had a look at /home/user/path/to/tester1.img ? I expect you will find it contains only the output of the ddrescue command, not the image.

If its an option, I would use SSHFS on "example" (or NFS or something else) to expose /home/user/path/to on the local filesystem across the network and then use ddrescue with its regular invocation, ie, or example

SSHFS uses "FUSE" to remotely expose a remote filesystem on a local machine. You can likely use commands on "example" like

  mkdir /m2 
  sshfs -C user@targetmachine:/home/user/path/to /m2
  ddrescue -d /dev/sda1 /m2/tester1.iso /m2/tester-dd.log

The "-C" in the SSHFS command above enables compression via SSH, this assumes that the network is a constraint rather then CPU.