History always repeats itself and sometimes that's good. Here's a second chance to be part of it: tmdtc.com

Tuesday 23 October 2007

Reminder: you can pipe through ssh

ssh is useful for more than just opening a terminal session to servers. You can also pipe standard input and output in and out of ssh. This is the command I used to compress a log file on the remote host and save it on my local disk, all in one command and not intermediate file saved on the remote host:

ssh host '( cd /usr/local/app/log/ && tar -jcvf - production.log)' > /tmp/app_production.log.tar.bz2

It is so useful I thought it was worth a reminder.

1 comment:

Paul Cobbaut said...

Als je mijn backup hoofdstuk hier bekijkt, dan zie je voorbeelden van ssh in combinatie met tar, cpio, gzip etc.