Pages

December 10, 2007

Fast remote dir copy using netcat

Hey, this tip I used so many times! For situations, where network is not a bottleneck, I like using netcat for remote dir copy. For example, I want to fast copy dir /opt/sybase (which has 50GB) from one machine to another. I will tell netcat to listen on port 2000 on destination host and wait for data. Then from source host I will connect to destination host and pump data in.

On destination host type:
cd /opt
nc -l -p 2000 | tar -xf -
edit: Newer netcat, command will looks like "nc -l 2000 | tar -xf -"
Next on source host type:
cd /opt
tar -cf - sybase | nc destination.host.ip 2000

Enjoy!