Rediscovery Of Netcat And Gzip
Lately I often caught myself downloading mysql nightly dumps over the network for testing on my own workstation. I was first doing the transfer of .dump.gz with sftp, gunziping each, and then pipe-feeing those to mysql one by one using xargs
. Afterwards I came to these discoveries:
- You can concat *.gz files and still have a stream that can be gunzipped properly. This property of transitive concatenation in gzip is a gift!
- Consequently you can stream concatenated .gz files other the network with netcat, gunzip the stream on the other end at once and feed it to mysql.
It comes down to this:
server$ cat *2012-09-21*.gz | nc -l 5000
client$ nc server-hostname 5000 | gunzip | mysql params
Published: 2012-09-29