Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have access to backup server via rsync protocol (only rsync, nothing else). Now, I want to fetch file from there (which is .tar.gz) and pass it directly to tar command, without saving the archive in local filesystem.

To visualize, with ssh access I could:

ssh remote_host cat backup.file.tar.gz | tar xzf -

And I will get uncompressed backup locally, without actually storing .tar.gz on local machine.

Is it possible to achieve when using rsync?

share|improve this question
add comment

4 Answers

to make it short: you can't. rsync works by talking between 2 instances of rsync (client- and server side), to find out the differences. tar is not able to speak 'rsyncish'.

share|improve this answer
    
but one of the clients could (theoretically) write somehow to pipe instead of file. –  user7385 Jun 29 '10 at 10:23
3  
The rsync protocol requires bi-directional communication - full duplex on a single channel. This is not possible with pipes, they are simplex only. All rsync ever sends to stdout is status information. –  David Spillett Jun 29 '10 at 12:46
    
Not sure what rsync protocol has to do with output. I am not talking about replacing rsync with tar. I am talking about making rsync client write file (for example downloaded with --whole-file option, to prevent seeks and checksum checks) to pipe, not to file. –  user7385 Jun 29 '10 at 16:13
add comment

Normally you could just use a named pipe, like so:

mkfifo mypipe
tar xzf mypipe &
rsync --inplace server:/remote/file.tar.gz mypipe

However, rsync is too smart for it's own good, since it recognizes that the remote file is a normal file and the local one is a pipe. So it first deletes the pipe, then transfers the remote file. scp doesn't have this problem, and will happily send the data into the named pipe (unfortunately that doesn't help you here).

share|improve this answer
add comment

I don't think so, but you might be able to use scp:

scp file /dev/stdout

will copy the file to standard output. You can add the necessary remote user and host information for the source of the file to the command line arguments of scp.

share|improve this answer
    
As I mentioned: I don't have ssh/scp. Just rsync access. –  user7385 Jun 25 '10 at 16:47
1  
@depesz: Sorry, I don't see where you mentioned that. –  Dennis Williamson Jun 25 '10 at 18:37
    
"I have access to backup server via rsync protocol." I didn't mention access by ssh because i don't have it. I also didn't mention other protocols - I just have rsync. –  user7385 Jun 25 '10 at 20:28
add comment

rsync can only the rsh or ssh protocol. If you are not using ssh, It must be using rsh. Simply substitute ssh with rsh command:

rsh remote_host cat backup.file.tar.gz | tar xzf -

share|improve this answer
    
rsync can only the rsync-protocol. it speaks it through whatever chanel possible. –  akira Jun 28 '10 at 6:50
    
@akira, In daemon mode, yes I forgot it does listen port 873. It can be configured to use rsh or ssh too without daemon running. –  TD1 Jun 28 '10 at 17:06
    
@Tim Deichelbohrer: no, always. if it runs via ssh the "daemon" (better "sender") is fired up on demand and is talking to the client via stdin/stdout. read samba.anu.edu.au/rsync/how-rsync-works.html "Process Startup" –  akira Jun 28 '10 at 17:23
    
@Tim: I don't have rsh/ssh access - as I said - I have only rsync access. –  user7385 Jun 29 '10 at 10:23
    
@akira: rsync doesn't require rsh/ssh. It has it's own tcp/ip server. –  user7385 Jun 29 '10 at 10:24
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.