Saturday, 26 July 2008

Bit-Copy a Hard Disk Over A Network

This method creates a disk image file for the backup using dd and nc (netcat). See also rsync

On the server (destination of the image file)
nc -l 5000 | of=disk.dd.gz

On the PC (disk to be backed up)
dd if=/dev/sda | gzip -9 | nc -q 5 hostname 5000

5000 is the listen port, you can choose any unused port you like

To restore the disk;

On the receiver (where the physical disk is)
nc -l 5000 | gunzip | dd of=/dev/sda

On the server (where the disk image is)
dd if=disk.dd.gz | nc -q 5 hostname 5000


Anonymous said...

Thanks. Great tip. I think you meant:

nc -l -p 50000 > disk.img

Brett said...

You are correct alfplayer, not sure how that one slipped through!

In fact, while testing just now I also realised that the -p is also superfluous and causes an error.