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 [email protected] "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 [email protected] dd of=image.gz
The above example will copy
image.gz to the user’s home directory.
- Although you can use
ddwhile a disk is in use, it should be avoided.
- Both disk and partition tables will be copied
fdisk -lon a system to see the composition of the partition tables