avoid rsync deleting vanished files on receiver

Matt McCutchen matt at mattmccutchen.net
Mon Oct 26 20:25:19 MDT 2009


On Wed, 2009-10-21 at 12:14 +0200, Hans-Christian Jehg wrote: 
> I have a rather curious problem. I rsync from a fileserver shared in via 
> cifs. This connection sometimes fails (don't worry, that is not the 
> question I have).
> I am not at all sure where it goes wrong, but in the end the result is 
> that rsync thinks certain files has disappeared. It could for instance 
> go wrong in the cifs client, but also in rsync when trying to read the 
> remote file (I am not using --ignore-errors) if no proper read checking 
> is in place (I do not think that this is the case but I would mention it 
> anyway).
> My immediate problem is that rsync proceeds happily and deletes any 
> vanished files in the end (--delete-after).
> rsync stops with exit code 24, but by then the damage is already done 
> (files deleted) .

On Fri, 2009-10-23 at 17:32 +0200, Hans-Christian Jehg wrote:
> The circumstance where this happens is now known, it is when requests
> to the shared in files returns "permission denied" from the file
> server...

Where are you seeing the "permission denied" text?  It would help if you
would post the exact output of rsync pertaining to the affected files.

When rsync's "stat" call on a source file fails, the behavior depends on
the returned error code.  If the error is ENOENT ("No such file or
directory"), rsync reports the file as vanished and sets exit code 24.
But if the error is anything else, including EACCES ("Permission
denied"), rsync sets the IOERR_GENERAL flag (which disables deletion
unless --ignore-errors is passed) and sets exit code 23.  So if rsync is
truly printing "Permission denied", it makes no sense that it would then
exit with code 24.

If your source filesystem is returning ENOENT for what is really a
permission denied error, that's the filesystem's problem, not rsync's.
Disabling the deletion of vanished files would be a misfeature, as
Carlos suggested.

On Sun, 2009-10-25 at 08:52 +0100, Hans-Christian Jehg wrote:
> no the exit code is 24...
> 
> I also sometimes get exit code 23, but then rsync does it correctly...
> 
> What would be the effect of the file system reporting "permission
> denied" while reading directories? A list with files missing ?

Precisely; that's why rsync disables deletion in such cases.

-- 
Matt



More information about the rsync mailing list