Home > Linux, Redhat > File copy comparison of rsync and netcat

File copy comparison of rsync and netcat

# Netcat with tar and compression is the fastest; here’s the test

1 GB file test copy times
source and destination server on 1Gb link

create file on source lindb01
dd if=/dev/random of=test.file bs=1024 count=1000000

Test with rsync
time rsync -av test.file lindb02:/tmp
22.318s

time rsync -azv test.file lindb02:/tmp
15.519s

time rsync -av -e ssh test.file lindb02:/tmp
22.546s

time rsync -av -e “ssh -C” test.file lindb02:/tmp
17.188s

time rsync -azv -e “ssh -C” test.file lindb02:/tmp
15.749s

Test with Netcat
Destination:
nc -l 2342 | tar -C /tmp -xzf –
Source:
time tar cz test.file | nc lindb02 2342
9.579s

Source:
time tar c test.file | nc lindb02 2342
9.606s

# Just unsure how long nc can hold a port open, but if we continuously feed data through
# it may stay open

Categories: Linux, Redhat
  1. John S.
    October 15, 2013 at 3:43 pm

    Your test parameter is not right because your input file is basically zero. Compressing a 1GB file made of zero will result a great compression ratio. Instead, you should use random, i.e.,

    dd if=/dev/random of=test.file bs=1024 count=1000000

    • October 16, 2013 at 5:23 pm

      Thank you for catching this, John. You are absolutely correct. I will change the post to reflect your comment.

  2. Sunny
    March 24, 2014 at 6:11 am

    you can not do differential tar using netcat but with rsync, you can just transfer the changed files. With tar, you will have to arrive at the diff yourself and then tar only the diff and send over netcat, which sort of is harder and takes longer.

    So, this applies only to the full backup.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: