Rsync to stdout?
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?
Solution 1:
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).
Solution 2:
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
.