SSH / TAR to copy over files

Using tar and ssh to efficiently copy files preserving permissions

This trick will tar a directory from a computer, but the file that it would normally create, is standard out, so it is redirected back to the script on the computer you are working on. The computer you are working on extracts the information directly, so there is no location where (redundant) files are stored.

ssh user@machine “tar czpf – /some//data” | tar xzpf – -C /new/directory

You are now directly copying data from the “machine-where-data-is” to the machine you are working on, using the benefits of tar (preserving permissions, links, etc) but not being hindered by the difficulties of tar. (making these possibly large files and so on.)
I used this trick to copy users directories from one machine to the other.

An alternative command, reverse and not crossing filesystem boundries:
tar cXpf – /some/important/data | ssh user@destination-machine “tar xpf – -C /some/directory/”