Friday, March 14, 2008

Tar + SSH

If you want to transfer a directory structure from your local machine to a remote host, there are obviously a lot of ways to do this. You could use a recursive scp, an rsync, ftp (god forbid), or a variety of other techniques. Another way that's assuredly less popular but has the advantage of letting you specify the compression method and providing options to preserve attributes verbatim, is to use tar and ssh with the following syntax:

tar cvjf - * | ssh whoever@machine.com "(cd /path; tar xjf -)"

The previous example uses bzip2 compression, which may save time for large transfers. Thanks to Nate G. for contributing this tip.

No comments: