rsync over stdin/stdout

Matt McCutchen matt at mattmccutchen.net
Mon Jun 2 20:45:04 GMT 2008


On Mon, 2008-06-02 at 11:27 -0700, Tony Mantler wrote: 
> So I've got this situation where I have two systems connected via a
> protocol that looks nothing at all like IP, and I'd like to be able to
> rsync between them.
> 
> I can, though, open a perfectly normal looking socket through various
> magic and trickery.
> 
> I've managed to get rsync to work by using the "rsync
> --rsh=mymagictransportprogram" style invocation, but for a number of
> reasons this isn't really a viable long-term solution for me. What I'd
> like to be able to do is either:
> 
> A: Set up stdin/stdout and exec rsync with some options that tell it
> that there's a remote rsync on the other end of those FDs, or
 
> Basically I need to set up the socket beforehand and then hand it to
> rsync somehow. This seems to be possible on the 'remote' end, but I
> haven't managed to figure out how to do on the initiation side.

First, you should use an rsync daemon if you aren't already; with the
remote shell mode, you have to get the server arguments across the
socket yourself, whereas the daemon protocol takes care of that.

There's an enhancement request for a "&3::module/src/" syntax to make
the client access a daemon over a socket supplied on a fd:

https://bugzilla.samba.org/show_bug.cgi?id=5220

In the absence of this enhancement, you can accomplish the same thing
using the RSYNC_CONNECT_PROG environment variable (or --rsh, but
RSYNC_CONNECT_PROG is slightly more convenient).  Have the
RSYNC_CONNECT_PROG inherit the socket from rsync and bridge the socket
to its own stdin/stdout for use by rsync.  Here's an example, assuming
the socket is already on fd 3 of the shell:

RSYNC_CONNECT_PROG='cat >&3 & cat <&3; wait' rsync -a foo::module/src/ dest/

The hostname, here "foo", doesn't matter, since RSYNC_CONNECT_PROG
overrides it.

> B: Call rsync as a library, passing it a socket and directory(^Hies) to
> sync with. (librsync doesn't seem to be quite what I want)

Rsync doesn't come as a library.  Librsync is perhaps misnamed: it
contains only rsync's delta-transfer algorithm for individual files. 

Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/rsync/attachments/20080602/10457d3c/attachment.bin


More information about the rsync mailing list