post transfer script for forcing perms

Matt McCutchen matt at mattmccutchen.net
Sun Nov 18 15:26:46 GMT 2007


On Sun, 2007-11-18 at 00:40 -0500, Eric S. Johansson wrote:
> I'm looking to see of it is practical to have an rsync server run a script after 
> a transfer finishes.

If you mean the server process invoked over remote shell, you could do
something like this:

rsync --rsync-path='rsync-and-fix-ogp' ...

and write a script called rsync-and-fix-ogp on the destination:

#!/bin/bash
rsync "$@" && chmod/chown...

If you mean an rsync daemon, you want the "post-xfer exec" configuration
parameter; see the rsyncd.conf(5) man page.

> I am moving files (python source) from windows (common 
> point of development) to a few linux machines.  big problem being 
> owner/group/perms are always wrong and python's module install process is
> fragile with respect to OGP.  Therefore, I want to run a script after 
> transferring a set of files so I can correct all of the 
> ownership/group/permissions from the Windows defaults to what I need.

You may be able to get the attributes right with some options to rsync
rather than a separate script.  Don't pass -o, -g, -p, or -a (which
implies -ogp), and then: use the --chmod option or the daemon's
"incoming chmod" parameter to fix the permissions, and run the receiver
as the desired user and group or set the daemon's "uid" and "gid".

Matt



More information about the rsync mailing list