This is my personal blog. I also have a professional blog at http://siliconsparrow.com/

21 November 2006

Using netcat with tar

Filed under: Nerd Notes — adam @ 8:46 am

This method will bulk copy files from one Linux machine to another. It will preserve all directory structures, links and permissions. It is very useful for backing up hard drives or transferring an entire directory to another machine.

For this example, the destination machine is 192.168.0.13 and I have chosen port 10001 but you can choose any port you like of course. Also you will need tar and netcat installed on both machines.

First, on the destination machine, run this command:

netcat -l -p 10001 | tar xv

And then on the source machine, run this command:

tar c * | netcat -q 1 192.168.0.13 10001

The ‘v’ option is, well, optional. I just like to view the progress of the operation as it goes.

If you want to do this over the Internet or through a modem, you might consider using the ‘z’ or ‘j’ option to compress the data on the way through.

1 Comment »

  1. Comment by Ben Stern — 11 March 2007 @ 8:23 am

    You might want to try rsync as well, which tunnels over SSH and preserves more attributes than you can shake a stick at, including directory structure and access time.

RSS feed for comments on this post.

Leave a comment

COMMENTS ARE DISABLED DUE TO EXCESSIVE SPAM. I'm sorry about this, I really love to read your comments but the amount of time I spend deleting spam is too much.


Powered by WordPress