Rsync to stdout?

10,505

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.

Share:
10,505

Related videos on Youtube

Admin
Author by

Admin

Updated on September 17, 2022

Comments

  • Admin
    Admin over 1 year

    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?

  • Dennis Williamson
    Dennis Williamson almost 14 years
    @depesz: Sorry, I don't see where you mentioned that.
  • Gerjack
    Gerjack almost 14 years
    "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.
  • Admin
    Admin almost 14 years
    but one of the clients could (theoretically) write somehow to pipe instead of file.
  • David Spillett
    David Spillett almost 14 years
    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.
  • Admin
    Admin almost 14 years
    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.
  • macetw
    macetw over 7 years
    Answer checkmark. @user7385