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
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
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.