Can I "drush rsync" with "chown @ destination"? I understand that drush rsync is, by design, capable of preserving uid:gid.

if I am synchronizing with drush rsync @site1 @site2, and uid:did exists on both site1, and site2, all is well.

How would I go about changing the uid:gid to a specific selection on site2, within drush's command/alias config?

For example, on site1 all files are wwwrun:www, but on site2 I want to save all files as bob:admins, neither of which exists on site1.

Is there an integrated solution?  I know I can use 'drush ssh @site2 "chown ..."' as a subsequent step. Can I instead define/chain the command in aliases.drush.rc?

Using "remote-user=xxx" certainly works, but, apparently, it is limited to users that are allowed SSH access on the remote box.

@ remote
egrep -i "allowusers" /usr/local/etc/ssh/sshd_config
    AllowUsers         root locuse testuser

@ local
whoami
    locuse
drush --remote-user=testuser rsync @siteA @siteB
    You will destroy data from locuse@siteB.loc:/srv/www/siteB/ and replace with data from /srv/www/siteA//
    Do you really want to continue? (y/n): y

@ remote
ls -al PROD/ | head -n 5
    total 248K
    drwsrws--- 10 testuser users 4.0K Mar  8 00:08 ./
    drwxrwx---  4 wwwrun   www   4.0K Mar  8 08:11 ../
    -rw-rw----  1 testuser users 6.5K Mar  6 17:31 authorize.php
    -rw-rw----  1 testuser users  64K Mar  6 17:31 CHANGELOG.txt
    -rw-rw----  1 testuser users  996 Mar  6 17:31 COPYRIGHT.txt


That doesn't address my particular issue/interest.

More clearly, what I want to do is ssh-in from local->remote as an authorized user ('locuse' or 'root'), but I have the remote files' uid:gid set to an existing pair, where the target uid does/will NOT have ssh-access (e.g., wwwrun:www).

Reading the output of "man rsync," I read:


  USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION


Then @siteB

mkdir -p            /path/to/target
chown -R wwwrun:www /path/to/target

vi /etc/rsyncd.conf
    transfer logging = true
    log format       = %h %o %f %l %b
    log file         = /var/log/rsyncd.log
    pid file         = /var/run/rsyncd.pid
    lock file        = /var/run/rsync.lock
    hosts deny       = *
    use chroot       = no
    [siteB]
        path = /path/to/target
        hosts allow = *
        comment = COMMENTS
        uid = wwwrun
        gid = www
        read only = no
        list = yes


and @local

whoami
    locuse
ls -al ~/SourceDir
    total 240K
    drwxrwxrwx  2 locuse users 4.0K Mar  8 10:42 ./
    drwxr-xr-x 27 locuse users 4.0K Mar  8 10:41 ../
    -rw-r--r--  1 locuse users 5.2K Mar  8 10:43 file1.txt
    -rw-r--r--  1 locuse users 2.8K Mar  8 10:43 file2.txt

rsync -av --rsh=ssh ~/SourceDir/ root@siteB.loc::SiteB


Checking on remote:

ls -al /path/to/target
    total 240K
    drwxrwxrwx  2 root   root 4.0K Mar  8 10:42 ./
    drwxr-xr-x 27 wwwrun www  4.0K Mar  8 10:41 ../
    -rw-r--r--  1 wwwrun www  5.2K Mar  8 10:43 file1.txt
    -rw-r--r--  1 wwwrun www  2.8K Mar  8 10:43 file2.txt


It ends up with exactly the end-state I'm after.
If you do not tell rsync to preserve the uid, then it will create all transferred files under the ownership of the user that you connected as.  The key, then, is to make sure that you put 'remote-user' =&gt; 'bob' in the site alias for your destination site.

The rsync flags I use to achieve this are -rlptz.  So, in my drushrc.php, I have:

$command_specific['rsync'] = array('mode' =&gt; 'rlptz');


See also:

http://drupal.org/node/1169776#comment-4612944

http://drupal.org/node/1343892

Supporting rsync modules in Drush would be awkward. If you want to use modules, it's probably best to call rsync directly.  e.g.:

rsync -av --rsh=ssh drush dd @siteA root@siteB.loc::SiteB

You would need to configure your SiteB module to point to the Site B Drupal root anyway, so it seems like there is little value to tying this to a site alias.