Piping tar datastream over SSH
How to use tar to copy everything in /usr/local/stuff to remote’s /backup (because I always forget how this is done),
cd /usr/local/stuff
tar cf - . | ssh remote "cd /backup; tar xf -"
Basically, you’re telling tar to tar up everything in your current directory (.) and send it to -, which is standard out; this is piped to ssh, which (once logged in) will send it to standard input of the process it runs, in this case tar.
Other way round:
ssh remote "cd /usr/local/stuff; tar cf - ." | tar xf -
will copy everything from /usr/local/stuff to your current directory.
(Original source: http://macosx.com/forums/unix-x11/16999-piping-tar-datastream-over-ssh.html)