transfer files with netcat
As I don’t use my arch laptop that much, I’ve figured that I can use it as a backup storage for my collections - collections of memes and movies.
Rsync is bloat?
Using some kind of a USB as an intermediary wouldn’t do the trick, because my meme collection is 14GB big (pathetic), whereas my movies take 139GB. My first though was to use rsync. I’ve never used rsync before, so I perused its man page and quickly found out that you can use:
rsync -vzP /some/path user@remote:/some/other/path
to sync the files. Then... I got a ssh error. I couldn’t be bothered to install a ssh server on my laptop, because that would only bloat my precious Arch Linux install. I continued the search.
Rsync is bloat, so let’s pipe stuff into some program
I’ve stumbled on this StackOverflow answer. Not only does this guy have a method that would allow me to transfer my movies without installing a ssh server, but he also claims that it’s faster (rsync shines more when it comes to syncing files that are ‘similar’). It turns out that you can compress the files with tar and then use netcat to send them over the network with:
tar -cpv --atime-preserve=system /path/to/ | nc -q 10 -l -p 45454
on the source machine, and
nc -w 10 X.X.X.X 45454 | tar -xpv
on the destination computer. The traffic isn’t encrypted at all, but that’s not a problem over LAN (e.g sending movies to my laptop). Albeit, encryption can be provided with ssh or with a VPN.
I think this method is very linux-like, because it combines two programs in some unusual fashion to create something new. I might consider replacing scp with the ssh version of this trick.