Netcat is a simple program which listens on a port of your choice and can send any data to a file. This is useful for backups.
I like using tar for backing up lots of files, and using the network to copy from one server to another, so on the destination machine, I open up a port:
nc -l -p 1337 > backup.tar.gz
Then on the source machine, I can use netcat to send the data across the network to the destination:
tar zlcvPpf - /location/to/backup | nc backup-destination.andydixon.com 1337
(where backup-destination.andydixon.com is the backup location, either IP address or FQDN)
The weird tar variables are (in order):
z – use gzip
l – packup only one file system (miss proc, cd-rom, nfs, samba and other mounts)
c – create the archive
v – verbose (see whats happening)
P – keep the leading / from paths
p – Keep file permissions
f – file to write to (the hyphen means that you are writing to stdout, which is piped to netcat)
If you want to recover data:
On the backup device:
nc -l -p 1337 < backup.tar.gz
This will spit the contents of the compressed archive to any open connections
On the target machine:
nc backup-destination.andydixon.com 1337 | tar -xz
Easy as pie.