Cookie

These days I had to reinstall Ubuntu to switch to version 18.04 LTS. I preferred to reinstall from scratch to avoid compatibility issues with old and obsolete packages repository. Since the directory /home/ well over 700GB and I have available a NAS (actually a small Linux Box) with a 1TB drive I decided to transfer the backup via LAN.

I investigated the choices: SCP, FTP, SMB, NFS… in all cases, the transfer would last several hours. Then I stumbled upon an article about “netcat” joined “tar” and “pv“, and the ability to transfer compressed files on LAN. Unlike previous methods netcat proved much faster thanks to compression although less secure (However, the files have been transferred in a protected home LAN).

For the uninitiated netcat is a small utility to the command line that reads and writes data across the network using the TCP or UDP protocols. “takes” is one of the most popular Linux commands from the user terminal: It serves to compress / decompress files. While “pv” (Pipe Viewer) It is a small monitor progress in the transfer.

First make sure you have the packages netcat and pv both of our systems. If not it will be enough to launch apt from the terminal:

$ sudo apt install netcat pv

Now we have to make sure that the computer that will receive the file is set up to broadcast. We launch the following command as a user root on the target computer:

# netcat -l -p 7999 | pv | take x

With this command that we are launching netcat:

  • -l” – It is configured to receive rather than to relay
  • -p 7999” – receive at the door 7999
  • pv” – as explained above will show a progress bar
  • tar x” – arrival of the compressed file “tar” will need to unzip

On the computer that will forward the file instead always we will launch this command as a user root:

# takes cf - * | pv | netcat 192.168.1.103 7999

The destination address in my case is 192.168.1.103. The command “tar cf -” It will copy the entire contents of the current directory on the target system and – as already seen – the files are then extracted.

Pay attention to the door. In my case I'm using port 7999 because it is not assigned to any service in particular. Obviously it is possible to modify this parameter, to do on both computers.

Caution

I've already written, but I would emphasize once again. This method It offers no security whatsoever. As is clear in these brief examples you do not need to either authenticate to the server, Customer born sul. I recommend using this method only protected LANs.

Not enough?


TheJoe

I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.