Tar through ssh

I love this command, which I’ve stolen from an article titled “Tar through ssh” by Graeme Winter on linux.com:

To transfer a (large, complicated) file tree from one machine to another, using stuff which is usually supported:

tar cf – stuff | ssh bob@wendy.no.where.com tar xf – -C /home/brian

Autopsy:

(tar cf – stuff) – tar stuff to the standard output
(| ssh bob@wendy.no.where.com) – pipe this to an ssh connection to wendy – where
(tar xf – -C /home/brian) – is run – which will untar the standard input and place the result in /home/brian….

Neat. This is better than using scp -r or tar then scp, because you can send > 4 gig files, and also retain softlinks etc which get broken by scp…

Or, to go the other way:

ssh bob@wendy.no.where.com tar cf – /path/to/stuff | tar xf – -C /final/destination

Advertisements

One thought on “Tar through ssh

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s