User Tools

Site Tools


gentoo:netcat_disk_copy

Netcat disc copy

NOTE: The netcat binary can be compiled with the 'static' useflag, thereby making it a standalone binary with no lib deps. (Can be copied to a livecd and run from there).

Copy an entire partition

The client is a computer with ip 192.168.0.10.

The client (the computer on which the image is to be stored) must run the following as someuser:

nc -l -p 10000 > partition.bz2

The server (the computer on which the disc to be copied resides) must run the following as root:

dd if=/dev/hda1 | bzip2 -9 | nc -q 0 192.168.0.10 10000

Copy all files on a filesystem

The client is a computer with ip 192.168.0.10.

The client (the computer on which the image is to be stored) must run the following as someuser:

nc -l -p 10000 > files.tar.bz2

The server (the computer on which the disc to be copied resides) must run the following as root:

tar --preserve -cvj . | nc -q 0 192.168.0.10 10000

Copy all files on a filesystem without compression

The client is a computer with ip 192.168.0.10.

The client (the computer on which the image is to be stored) must run the following as someuser:

nc -l -p 10000 > files.tar

The server (the computer on which the disc to be copied resides) must run the following as root:

tar --preserve cv . | nc -q 0 192.168.0.10 10000

Restoring files from tar

Assuming the server (the computer to have its files restored) has ip 192.168.0.59

On the client (the computer containing the backed up files) run the following:

nc -l -p 10000 | tar --preserve -xvf -

On the server, change to the directory into which the files should be restoed and run the command:

cat files.tar | nc -q 0 192.168.0.59 10000

Restoring partition from tar

TODO

Restoring disk from bz2 archive

Sender:

bzcat -d centos_6.4_minimal_desktop.dd.bz2 | nc -q 0 192.168.0.51 10000

Receiver:

nc -l 10000 | dd of=/dev/sda
gentoo/netcat_disk_copy.txt · Last modified: 2013/10/28 08:19 by deva