1

I am trying to backup a remote server to my machine. I am trying something like

ssh user@ip "dd if=/dev/sda" | dd of=~/backup.img

But that obviously doesn't work. Other variants that don't work.

  • ssh user@ip "sudo dd if=/dev/sda" | dd of=~/backup.img
  • ssh user@ip -t "sudo dd if=/dev/sda" | dd of=~/backup.img

I have public key authentication set up. Note that even after compression, the remote machine can not hold its own backup. What do I do?

(Note in the long run I want to try and put this in an automatic script, but I just want a backup for now.)

Note: I should mention that I don't want to just back up the files (like with rsync) but to have a complete image that I can just drop on a new hard-drive should this one go belly up with little hassle.

terdon
  • 242,166
  • 1
    using 'dd' is an incredibly inefficient way of backing up your disk, even if you want to have a complete image. If you wanted a true disk-level backup of your system, use your filesystem's 'dump' tool (for example, for ext2/3/4, use the dump command.) – jsbillings Jan 25 '14 at 22:40

1 Answers1

3

Something like this should work:

ssh user@ip sudo -S dd if=/dev/sda > backup.img 

You don't need to pipe to dd, you can just redirect the output into a file.

terdon
  • 242,166