Monthly Archives

April 2018

Replicating Linux Machines across a Network

This command will replicate a running machine into a remote machine container.
The source machine can be online and running, the remote machine should be booted via a Linux Live Image.   The destination machine should also have the same or larger disk size than the source machine.

Sending Machine
dd if=/dev/sda bs=16M conv=sync,noerror status=progress | gzip –9 -cf | nc destinationmachineip preferredport -q 10

Receiving Machine
nc –l –p preferredport | gzip –dfc | dd bs=16M of=/dev/sda

It is worth doing some test copies if you have a large image to send, or are on a slow network, altering the block size (bs=) and gzip compression amount (-9).  Particularly on the latter, on a fast network, you may be better off using lower compression, as the CPU cycles required for compression may in fact take longer than sending the data uncompressed or at a lower compression rate.

You can also use other compression programs like pigz to achieve better performance.