LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-08-2006, 03:27 PM   #1
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
Question Piping archive to remote host


I wanted to do something like this:
Take a local directory,
- tar gzip/bzip2 it
- ssh + cat it to a remote machine

The only problem is, the only guide I found on the 'net was
Code:
 Backup with local compression and remote storage

tar cf - dirname | gzip -c | ssh remotehost "cat > ${TMPFILE}.tar.gz"
which seems to require a temp file. Or am I misinterpreting this, and that ${TMPFILE} is the name of the file to be created on the remote machine? (It is an environment variable in the guide).

I can't use a local temp file expressly because the resulting tgz > free space.

Sorry for the banal question, I've never been really good with piping. *blush*

Last edited by michaelsanford; 02-08-2006 at 03:28 PM.
 
Old 02-08-2006, 03:51 PM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
I assume you're using the Linux.com article as your guide?

I'd imagine that using "tar cjf" would work - the "j" flag adds bzip2 compression, as shown in the tar man page. . . Altho I believe the example you show is indeed making the TMPFILE file at the remote site. Just swapping "gzip" for "bzip2" would probably work

Last edited by oneandoneis2; 02-08-2006 at 03:57 PM.
 
Old 02-08-2006, 06:54 PM   #3
born4linux
Senior Member
 
Registered: Sep 2002
Location: Philippines
Distribution: Slackware, RHEL&variants, AIX, SuSE
Posts: 1,127

Rep: Reputation: 49
try something like this:

tar cvf - localdir/ | ssh user1@remotehost "gzip -c > backup.tgz"

(note: not all systems has the compress option - i'm doing this on AIX so the gzip redicrection
 
Old 02-09-2006, 08:44 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
For moving directories (and subdirectories) between computers, I like to use scp , like this:
scp -pr /path/to/directory hostname:/path/to/destination
Or, if you just want to move one file:
scp -p /path/to/file hostname:/path/to/destination
Hope this helps.
 
Old 02-09-2006, 10:40 AM   #5
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
yes, why not just use scp? it uses the same authentication as the any other ssh connection (e.g. ssh-ageant works)....
 
Old 02-10-2006, 06:41 PM   #6
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Original Poster
Rep: Reputation: 30
tredegar, satinet, thanks for your replies but you probably glanced over my original post a little quickly I needed a way to pipe a local folder to a tar.gz on a remote machine, like oneandoneis2 and born4linux mentioned.

Thanks to all who replied, of course!

PS For other things, I love scp, it's great, too bad it doesn't compress inline.
 
Old 02-11-2006, 02:01 PM   #7
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
this code wont work:

tar cf - dirname | gzip -c | ssh remotehost "cat > ${TMPFILE}.tar.gz"

how are you defining TMPFILE? what are you cating? i'm not sure that gzip produces an output as such to pipe into ssh.

i dont understand where cat comes into this. are you wanting to create an archive or expand it at the other end??

if you want to tar accross a network you would using something like:

tar cf - dirname | ssh remotehost '( tar xfB - )'

or are you wanting to create a gzip at the other end? how can you cat and archive or tar ball??
 
  


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
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 35 10-23-2017 12:21 AM
Mount remote host mrbabis Linux - Newbie 1 10-24-2005 05:10 PM
MRTG -> remote host Soulstealer Linux - Networking 3 06-27-2005 06:11 PM
Resolving <www.some remote host>.... failed: Host not found. koodoo Linux - Newbie 2 06-27-2005 08:48 AM
Best way to connect to a remote host? neilcpp Linux - Networking 1 09-01-2003 01:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:23 AM.

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