"Cannot delete non-empty directory"/"Operation not permitted" with file-creation on target-server

Matt McCutchen matt at mattmccutchen.net
Wed Jul 14 09:12:21 MDT 2010

On Wed, 2010-07-14 at 09:35 +0200, Carsten Deibert wrote: 
> I was searching for an answer myself for quite some time without success, so
> I hope somebody can clarify...I use rsync to sync webcontent from one server
> to another.
> Apache-details:
> * Apache runs as nobody:nogroup. 
> * Source-Server-Rights htdocs: The rsync-user gains access via o+rx
> * Destination-Server-Rights htdocs: The rsync-user is in the group
> 'nogroup', gains access via owner rsync-user and g+rwx, htdocs-group is
> 'nogroup'
> I use the following command:
> /usr/bin/rsync -topglrcze ssh --delete --force --exclude='example.zip'
> /vol/www/example/htdocs/ user at destination-server:/vol/www/example/htdocs/
> This works fine except in the following scenarios:
> 1. On the destination-server in e.g. /vol/www/example/htdocs/test there
> already is an 'example.zip' --> I will receive the following error: "cannot
> delete non-empty directory". I tried to overcome this with a rsync-filter,
> but without success. How can I use the exclude-pattern even if such an
> excluded file exists on the destination server ?

That message is only a notice, not an error, and I even opposed printing
it by default (https://bugzilla.samba.org/show_bug.cgi?id=3825#c11).  If
you are happy with the behavior you get, you can ignore the message.
Or, you might want --delete-excluded. 

> 2. Whenever the Apache-Process of the destination server writes in its
> webfolder (e.g. /vol/www/example/htdocs/test/example.htm with
> nobody:nogroup) the rsync-user, even has full rights via 'nogroup', will
> give me an "Operation not permitted" wth the next synchronisation.

Ah, but rsync doesn't have full rights: some operations, such as setting
a file's mtime arbitrarily, require ownership of the file and permission
cannot be granted to others.  I consider this a defect in the POSIX
filesystem model.  Typically only the directories are the problem
because an mtime difference on a regular file will trigger rsync to
transfer and recreate it, so --omit-dir-times would stop the errors.


More information about the rsync mailing list