Instead of creating a tar-ball in the server, I used netcat (or known as nc) to stream the files over to another server while running the tar command.
On the server, run the following command:
tar czvf - /opt | nc -l -p 8888 -cThis creates a tar gzipped file of the /opt directory and put the output to stdout. Pipe the output of tar to netcat (nc) which is listening (-l) to port (-p) 8888. The additional -c option is to close the connection after EOF on stdin. If this option isn't there, netcat will continue waiting for data from stdin. This is not what I want as I need the backup action to end properly in order to place it in a script.
On the receiving end, just run the following command:
nc 10.112.133.12 8888 > opt.tar.gzThis instructs netcat (nc) to connect to the IP on port 8888 and write the output to opt.tar.gz.
Well, there you have it. A quick and dirty way to transfer a backup image if you're short of space to create the backup file.
2 comments:
If netcat is not available, you can do that with ssh too..
tar czvf - /opt | gzip -9 | ssh username@server "cat >opt.tar.gz"
It'll be slower than netcat but it's encrypted.. :)
Thanks for the tip. It's already quite slow with nc. But hey, performance can take a little hit if it's secured :)
Post a Comment