rsync-ing from two locations with same filenames (at different versions)

Mojca Miklavec mojca.miklavec.lists at gmail.com
Wed Jan 30 08:48:01 GMT 2008


On Jan 30, 2008 4:16 AM, Matt McCutchen wrote:
> On Mon, 2007-11-19 at 14:39 +0100, Mojca Miklavec wrote:
> > However, the following case fails:
> >
> > mkdir -p full/dir1
> > mkdir -p full/dir2
> > mkdir -p new/dir1
> > # also, is there a way to ask rsync to ignore this location if it doesn't exist?
>
> Unfortunately not.  I agree that this feature is useful, and I might
> implement it at some point as a patch.
>
> > mkdir -p new/dir2
> >
> > echo "a" > full/dir1/a.txt
> > echo "b1" > full/dir1/b.txt
> > echo "c" > full/dir1/a.txt
> > echo "d" > full/dir2/a.txt
> > echo "b2" > new/dir1/b.txt
> >
> > rsync -rpztlv --delete full/dir1/ full/dir2/ dest
> > rsync -rpztlv --delete new/dir1/ new/dir2/ full/dir1/ full/dir2/ dest
> >
> > dest/b.txt now contains "b1", which is the wrong one. Is there a way
> > to force rsync to take b.txt from "new/dir1/b.txt" instead of taking
> > if from "full/dir1/b.txt"?
>
> All that is going on here is that, if you run the sequence of commands
> quickly, the files containing "b1" and "b2" pass the quick check with
> each other because they have the same size and mtime.  Thus, even though
> the second rsync run does have the "b2" file in its file-list, it
> incorrectly assumes the destination file (which contains "b1" from the
> first run) does not need to be updated.  To avoid this problem, use
> --checksum or --ignore-times.

Neither helps. Even if I have a file of differest size and with a
different timestamp, and even if I add --checksum or --ignore-times,
the old file in dest won't be modified (overwritten by a newer file).

It's a pitty that there is no way to do it but I have to live with it.
I can still do

rsync -rpztlv --delete full/dir1/ full/dir2/ tempdir
rsync -rpztlv          new/dir1/ new/dir2/ tempdir
rsync -rpztlv --delete tempdir dest

which is ugly an inefficient, but if there is no better way ...

Thanks again,
    Mojca


More information about the rsync mailing list