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.

1
  • 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
    Commented Jan 25, 2014 at 22:40

1 Answer 1

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.

3
  • cool, works well with piping through gzip too Commented Jan 25, 2014 at 18:47
  • So how this works is the -S flag is on sudo, and it causes it to ask for the password from the typing terminal, not the machine its on, right? Commented Jan 25, 2014 at 21:44
  • @PyRulez Using cat instead of dd is often a little faster: ssh user@ip sudo cat /dev/sda >backup.img (but you should heed jsbillings's recommendation and use a proper backup tool). Commented Jan 25, 2014 at 23:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .