RSync ignores symbolic links by default (warning written out).
Scenario: 'dirA' contains files and links and should be synchronized with 'dirB' and vice versa.
rsync -v --delete dirA dirB
copies files from A to B and lets links in A. The opposite command
rsync -v --delete dirB dirA
should now do nothing because directories are "in sync". Instead of this the command deletes the links in A.
I argue that links should not be deleted if they are ignored in the opposite direction. Otherwise it is not possible to write "symmetric commands". Of course the same is true for the other variants of link treatment (not tested by me).
Created attachment 2350 [details]
Limit deletions to exclude items we aren't transferring
Here is a simple patch for the CVS version that limits the deletions to skip symlinks, device files, and other special files if they are not being synchronized. I'm considering this patch for inclusion in 3.0.0.
I notice that the patch only affects extraneous "special" files immediately inside file-list directories, not those in extraneous directories. This is enough for the commands to be symmetric, but deleting an apparently empty directory on one side could result in the unexpected loss of a lot of special files on the other side. I'm not sure whether this is a strong enough reason that rsync should protect special files in extraneous directories and pin their parent directories.
I'd like to broaden this ticket to include an analogous issue with --min-size and --max-size:
(In reply to comment #2)
> I notice that the patch only affects extraneous "special" files immediately
> inside file-list directories, not those in extraneous directories. [...]
The goal of this ticket is really to make --min-size/--max-size behave more like an ordinary exclude. And the decision to be made is whether this exclude is "perishable".
I realize that different users may have different expectations about how these options behave. See, for example, the following request that --max-size behave as a real hide rather than a transfer rule:
So probably the most general solution is to add filter rules based on size and a new filter action that means "show but don't process" to emulate a transfer rule.
(In reply to comment #4)
> The goal of this ticket is really to make --min-size/--max-size behave more
> like an ordinary exclude.
Whoops, the ticket was originally about the file-type options (-r/-d, -l, --devices, --specials), but the point is the same.