Rsync to stdout?

7

2

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?

user7385

Posted 2010-06-25T16:34:50.167

Reputation:

Answers

4

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).

Brian

Posted 2010-06-25T16:34:50.167

Reputation: 1 009

Answer checkmark. @user7385 – macetw – 2017-01-27T18:25:58.147

0

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.

Paused until further notice.

Posted 2010-06-25T16:34:50.167

Reputation: 86 075

As I mentioned: I don't have ssh/scp. Just rsync access. – None – 2010-06-25T16:47:36.330

2@depesz: Sorry, I don't see where you mentioned that. – Paused until further notice. – 2010-06-25T18:37:04.350

"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. – None – 2010-06-25T20:28:32.953

0

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 -

TD1

Posted 2010-06-25T16:34:50.167

Reputation: 155

1rsync can only the rsync-protocol. it speaks it through whatever chanel possible. – akira – 2010-06-28T06:50:24.763

@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 – 2010-06-28T17:06:21.233

1

@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 http://samba.anu.edu.au/rsync/how-rsync-works.html "Process Startup"

– akira – 2010-06-28T17:23:21.083

@Tim: I don't have rsh/ssh access - as I said - I have only rsync access. – None – 2010-06-29T10:23:43.027

1@akira: rsync doesn't require rsh/ssh. It has it's own tcp/ip server. – None – 2010-06-29T10:24:08.920

@depesz: i know that. that was not the point of my comment. – akira – 2010-06-29T10:37:08.470

@akira - sorry, misunderstood. – None – 2010-06-29T12:38:58.040

I learn something new everyday :-), thanks! – TD1 – 2010-06-29T19:40:29.770

0

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'.

akira

Posted 2010-06-25T16:34:50.167

Reputation: 52 754

but one of the clients could (theoretically) write somehow to pipe instead of file. – None – 2010-06-29T10:23:04.057

3The 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 – 2010-06-29T12:46:47.310

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. – None – 2010-06-29T16:13:02.813