Mojca Miklavec
2007-Nov-19 13:40 UTC
rsync-ing from two locations with same filenames (at different versions)
Hello,
I would like to have a full repository, say, holding files
full/a.txt (version 1)
full/b.txt (version 1)
full/c.txt (version 1)
and a repository of updates, for example
new/b.txt (version 2 - newer)
Then, I would like to call
rsync [flags] new/ full/ destination
to get
destination/a.txt (v.1)
destination/b.txt (v.2)
destination/c.txt (v.1)
This simple case works OK and consistently.
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?
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"?
Thanks a lot,
Mojca
Matt McCutchen
2008-Jan-30 03:16 UTC
rsync-ing from two locations with same filenames (at different versions)
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. Matt