[PATCH] --omit-dir-changes, qsort<>mergesort issues

Matt McCutchen hashproduct+rsync at gmail.com
Mon Jun 12 18:11:59 GMT 2006


On Thu, 2006-06-08 at 13:48 +0300, Antti Tapaninen wrote:
> Here's a new description of the process that hopefully makes 
> my goals more clear. [...]

I think I understand now.  Your goal is to manage / so that it consists
of files from these three sources (in decreasing priority):
- /alt/local
- /alt/root
- Vendor files
There is an additional consideration: the vendor will change files
directly to /, and those changed files should be overridable
by /alt/local and /alt/root.  They must be kept somewhere so that they
can be reinstated when /alt/local and /alt/root no longer override them.

And your steps are:
(1 and 2) Copy the new /alt/{root,local} to /, backing up overwritten
files in / that are not explained by the old /alt/{root,local}.  (Step 1
copies the files that would need backing up with backup enabled; step 2
copies everything else with backup disabled.)
(3) Remove files from / that were in the old /alt/{root,local} but are
not in the new /alt/{root,local}.
(4) Reinstate the most recent backup of each such file.

My first impulse was to start over and try to come up with a simpler and
more reliable backup procedure, but one was not forthcoming.  Instead, I
have some workarounds for the directory attribute problems.

- To get the correct attributes on the backup directories, you could run
an additional
	rsync --existing --include=*/ --exclude=*
from / to /alt/backup/SOMETHING after step 1.

- When restoring in step 4: --files-from is more suited than a bunch of
excludes for transferring specific files, but it is incompatible with
multiple source arguments.  Perhaps you could run a separate
	rsync --ignore-existing --files-from=<files unlinked in step 3> from
each backup directory (in reverse order) to /.  This way, the only
directories in the file list are the ones actually being restored (those
that are merely parents of restored files are omitted), and only those
directories get their attributes reset from the backup.

Do these measures help?

Separately, we should look into stable sorting.  Maybe, instead of
replacing qsort with another sorting function, we can just keep an
indication of the original order somewhere and use this order to break
ties in file_compare().  If we can count on file_structs being laid out
in memory in the order in which they were received, this tie breaking is
as simple as comparing pointers.

Matt



More information about the rsync mailing list