Copy a diskimage to a remote server

Recently, I had to mirror an entire disk from one server to another. I wanted to know what the fastes solution was to do this (250GB disk image).

I stumbled upon a blog post, which shows that using netcat was the fastest way, as sshd could take up some precious cpu ticks. Considering A) our source server was quite old, B) running in production, and C) I was copying this on an internal network (remember, this is unsecure copying). I went for it:

On the source server:

$ dd bs=16M if=/dev/sda|bzip2 -c|nc serverB.example.net 19000

On the target machine:

$ nc -l 19000|bzip2 -d|dd bs=16M of=/tmp/disk.img

This will read the data in chunks of 16M, bzipped2 to the target machine, which will fetch the data, unbzip the blocks, and write them to a disk image file.

The 250GB was copied in under 24 hours (around ~3MB/s, ~24mbps), which was quite ok on a busy network.