rsync --link-dest option with the destination directory containing old files.

Dave Dykstra dwdrsync at drdykstra.us
Tue Dec 23 16:00:55 GMT 2008


On Tue, Dec 23, 2008 at 11:45:36PM +1100, David Overton wrote:
> 2008/12/23 Robert Bell <Robert.Bell at csiro.au>:
> > It seems to us that there is a good case for the enhanced functionality.
> >
> > "When a file is found in the destination which should be replaced by one
> > in the source, look in the --link-dest directory first for a candidate,
> > and hard-link that in preference to doing a copy from source to
> > destination."
> 
> I would also very much like to see this feature.  Indeed, this seems
> far more logical than the current --link-dest behaviour and it's what
> I assumed --link-dest would do until I read the man page thoroughly
> (you have to follow the references back from --link-dest to
> --copy-dest and then --compare-dest and even then the only mention of
> the actual behaviour is a parenthesised comment "(if the files are
> missing in the destination directory)").  I be interested to know what
> use cases the current  behaviour was designed for,  because I can't
> see any advantage to not making use of the --link-dest file if it's
> available.  Providing the proposed alternative behaviour as an extra
> option, if not the default for --link-dest, would be very useful.

That's a parenthetical comment in --compare-dest because that's normal
rsync behavior.  If a file already exists at the destination, rsync
assumes as normal that it has to compare against it when copying the
file from the origin.  The *-dest options only come into effect when
the destination file is missing.  You're asking to have an option that
will always ignore the destination file, then behave as --link-dest
does now, and then overwrite the destination?

I don't understand what's the point of doing link-dest if you're not
going to keep around a linked copy of the entire directory tree, so I
don't see why you would right away rm -r an old tree.  Describe more
fully how you want to the disk to be left after the operation and what
you're trying to accomplish.  Depending on what you're trying to do,
there may be another combination you can use.  Rob gave the example of
    rsync -a --link-dest=../backup.1 source/ backup.0/
where backup.0 already had files in it.  Is it that you're trying
to alternate between backup.0 and backup.1 so you have two complete
backups with as much hardlinked between them as you can?

- Dave


More information about the rsync mailing list