3

I'm trying to synchronize two local drupal repositories using the following command:

drush rsync

My environment: - drush 6.1 - Mac os X 10.9 - drupal 7.24

I have followed standard security recommendations for Drupal and configured permissions with:

MBPC:files pc$ pwd
/Users/pc/Sites/mysite.dev/sites/default/files
MBPC:files pc$ ls -al
total 8
drwxrwx---+ 8 _www  staff  272 18 jul  2012 .
drwxr-xr-x+ 4 pc    staff  136 23 nov 15:08 ..
-rwxr-----+ 1 pc    _www   477 21 nov 15:19 .htaccess
drwxrwxr-x+ 3 _www  staff  102 18 jul  2012 color
drwxr-xr-x+ 3 _www  staff  102 22 nov 09:53 ctools
drwxr-x---+ 3 _www  staff  102 23 mai  2012 pictures
drwxr-x---+ 3 _www  staff  102 23 nov 16:24 private
drwxr-xr-x+ 2 _www  staff   68 24 oct 17:37 styles

The user pc is a member of the _www group.

The .htaccess file contains (following the latests Drupal security warnings) as follows:

# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

There is a similar .htaccess file in the private subdirectory.

I'm using the following command:

$ drush rsync @mysite.dev @mysite.local 

and I get this error message:

You will destroy data from /Users/pc/Sites/mysite.local/ and replace with data from /Users/pc/Sites/mysite.dev//
Do you really want to continue? (y/n): y
rsync: failed to set times on "/Users/pc/Sites/mysite.local/sites/default/files": Operation not permitted (1)
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/color" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/ctools" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/pictures" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: recv_generator: mkdir "/Users/pc/Sites/mysite.local/sites/default/files/private" failed: Permission denied (13)
*** Skipping everything below this failed directory ***
rsync: mkstemp "/Users/pc/Sites/mysite.local/sites/default/files/..htaccess.bVe3a4" failed: Permission denied (13)
rsync: failed to set permissions on "/Users/pc/Sites/mysite.local/sites/default/files/styles": Operation not permitted (1)
rsync: failed to set times on "/Users/pc/Sites/mysite.local/sites/default/files": Operation not permitted (1)
rsync: failed to set permissions on "/Users/pc/Sites/mysite.local/sites/default/files/styles": Operation not permitted (1)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
Could not rsync from /Users/pc/Sites/mysite.dev// to /Users/pc/Sites/mysite.local/                                                              [error]
  • File ownership is _www:staff, and staff doesn't have write access to those folders. Since you're unlikely to be running a shell as _www you need to give yourself (pc) permission to write to those folders – Clive Nov 23 '13 at 20:16
4

You cannot change the file timestamps or change permissions by being a member of a group, you have to be the file owner, or root. If you cannot be the other of that file, you might need to avoid trying to set permissions at all.

So you may try to modify your drushrc file (e.g. sites/default/drushrc.php) and add the following arguments for rsync command:

$command_specific['rsync'] = array('mode' => 'rlptzO', 'verbose' => TRUE, 'no-perms' => TRUE);

If running rsync on remotes, edit your aliases.drushrc file (e.g. sites/default/aliases.drushrc.php) and add something like:

$aliases['mysite.dev'] = array(
    // here are your settings such as uri, root, remote-host, etc.

    'command-specific' => array (
      'rsync' => array('mode' => 'rlptzO', 'verbose' => TRUE, 'no-perms' => TRUE),
    ),
);
2

This is really a permissions issue, not a Drush / Drupal question, but here goes. (Clive is right, but here's a little more detail.)

I was skeptical about your claims about not being able to find the answer with google, so I searched myself for rsync: failed to set times and was surprised that I could not easily find the answer to this.

If you are doing a remote rsync, then you only need write access to the target file to successfully do the copy, but you need to be the owner of the file to set the times. Since you have different owners for different files, setting the times on everything will be difficult, unless you want to rsync as root. I don't really recommend that; my preference is to make all of my files owned by a special user, www-admin, and set the group to something the web server belongs to. I then set the group write bit on files and directories that should be writable by the webserver, and clear it everywhere else.

With this setup, you just need to make sure that the remote user in your Drush alias is www-admin -- or continue using 'pc', if you prefer, but make 'pc' the owner of everything & you'll be okay.

Update:

When using this permissions scheme, it is also helpful to add the following to your drushrc.php file:

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

This will cause drush to use the flags -rlptz when calling rsync. See man rsync for details on the various rsync mode files available.

  • 3
    You may add O (--omit-dir-times) as well to your argument list to avoid it trying to set modification times on directories. Also consider --no-perms. – kenorb Apr 25 '14 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.