Wednesday, November 18, 2009

Network backup with NC and TAR

Backup to another host through NetCat command. It can be useful if there is no space for local backup or just for file transfer between hosts.

nc -l -p 8081 >/tmp/nc.dump #just listen on port 8081 and rewrite to stdout

then send something in raw to remote host:

tar c /opt/music | nc -w 2 HOST 8081
cat /tmp/mp3.file | nc -w 2 HOST 8081

-w 2 - wait silence for 2 seconds at stdin of NC and exit
.