Showing posts with label Tips and Tricks. Show all posts
Showing posts with label Tips and Tricks. Show all posts

Monday, June 25, 2007

Transfering multiple files with netcat

Today I needed to backup some files from one server to another. The servers sit next to one another on the network. Usually I use scp or rsync to move files around, but today I felt like trying something different.

First I considered using FTP. However, I do not like running FTP servers and didn't feel like configuring the daemon.

Then I thought of netcat. A quick Google search got me this page: http://www.oreillynet.com/pub/h/1058

However I want to transfer multiple files (all in the same directory). So I decided to use tar, and instead of creating a file, I would pipe it's output through netcat.

On the Receiving Computer (Server):
nc -v -w 30 -p 5600 -l | tar -x


And on the Sending Computer (Client):
tar -c * | netcat -v -w 2 10.0.0.2 5600;


The files transfered fast (2 min 20 seconds for 1.6 Gigs). I ran a md5sum on the client and server to confirm, and everything was perfect.