LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2011, 12:56 PM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
How to tar over ssh?


Code:
tar zcvf - /apps/software/something | ssh root@205.15.134.32 "cat > /backups/dir/something.tar.gz"
how do I reverse this?

I would like to ssh from this machine to another and tar a file back to this machine over the ssh session.
 
Old 05-19-2011, 01:49 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

If I am getting it correctly what you are looking for is to ssh a machine, create tar.gz file there and send it back to original machine over ssh. Is that correct? If that is the case I would suggest you to use scp as follows:


tar -cvf testing.tar.gz testing && scp -vrp /root/testing.tar.gz root@xxx.xxx.xxx.xxx:/root/

Command before && will create a tar and scp will copy it over to the machine from where you have ssh to this machine.

where for tar:

c=create
v=verbose
f=file_name

Where for scp:

v=verbose
r=recursively
p=preserve permissions
xxx=ip address of the destination server dont forget the : after that

Last edited by T3RM1NVT0R; 05-19-2011 at 02:47 PM.
 
1 members found this post helpful.
Old 05-19-2011, 06:18 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
To create a tarball on a remote host and pull it from there:

Code:
$ ssh foo@host.local "tar cf - /some/dir" > /san/backups/some_dir.tar
By sending the tarball to stdout, you can pull it over ssh without having to create it on the remote host's filesystem.
 
1 members found this post helpful.
Old 05-24-2011, 02:20 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by anomie View Post
To create a tarball on a remote host and pull it from there:

Code:
$ ssh foo@host.local "tar cf - /some/dir" > /san/backups/some_dir.tar
By sending the tarball to stdout, you can pull it over ssh without having to create it on the remote host's filesystem.
Exactly what I was looking for.

Cheers.

Thanks to T3RM1NVT0R as well for the original reply.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using tar and ssh together rafiki8 Linux - General 6 12-18-2008 09:41 AM
problem with tar over ssh Guttorm Debian 14 01-22-2007 01:00 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
tar | ssh (tar > .tar) syntax issues EarlMosier Linux - Software 6 12-21-2006 12:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration