How do DD from one server to another

Background

DD is an incredibly powerful Linux Utility that allows you to copy disks, partitions, and files from one place to another. This article explains how to remotely backup a disk partition from one location to another using SSH.

In this example below local is the computer to where you want the files copied, and remote is the computer which files you want to be copied.

On the local computer:

$ ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz status=progress

The above command logs into the remote computer, runs the dd command to specify dev/sda must be copied. It pipes the input to gzip for compression and then to the output a file called image.gz on the local disk.

If you’re doing this from the opposite direction (the remote computer to a local computer), do:

$ dd if=/dev/sda status=progress | gzip -1 - | ssh user@local dd of=image.gz

The above example will copy image.gz to the user’s home directory.

Notes:

  • Although you can use dd while a disk is in use, it should be avoided.
  • Both disk and partition tables will be copied
  • Use fdisk -l on a system to see the composition of the partition tables

Reference:
https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-disk

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top