--link-dest copying modified files

it-rsync at ml.epigenomics.com it-rsync at ml.epigenomics.com
Tue Jan 23 13:41:55 GMT 2007


It's me again with another --link-dest issue:

I am using dirvish (www.dirvish.org) to create daily backup on disk

dirvish is using rsync with --link-dest pointing to the last good image.
This creates images with hardlinks to unmodified files. So far so good.

Now I want to create a "current" filetree with hardlinks pointing to the
last image.

rsync -vaH --delete --stats --numeric-ids -x --link-dest=/path/to/lastimg /path/to/lastimg /path/to/current

This works except when an existing file has been modified and is now
"new" (and not the n'th hardlink) in the image. This file is copied to
the "current" directory. A hardlink pointing to the file in lastimg is
not created.

If a new file has been created in between the dirvish runs it perfectly
gets hardlinked in the "current" directory.

Is that intented behaviour?

You can easily reproduce the issue with the following commands:

# create source dir
mkdir -p /tmp/rsync/src
# create 1st file
echo 1 > src/a
# create 1st "backup" image
rsync -vaH --delete --numeric-ids -x /tmp/rsync/src/ /tmp/rsync/1/
# create "current" dir with hardlinks from 1st image
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/1/ /tmp/rsync/1/ /tmp/rsync/current/
# create 2nd file
echo 2 > src/b
# create 2nd image
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/1/ /tmp/rsync/src/ /tmp/rsync/2/
# create "current" with hardlinks from 2nd image
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/2/ /tmp/rsync/2/ /tmp/rsync/current/
# modify 1st file
echo 3 >> src/a
# create 3rd image
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/2/ /tmp/rsync/src/ /tmp/rsync/3/
# create "current" with hardlinks from 3rd image
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/3/ /tmp/rsync/3/ /tmp/rsync/current/

The last call to rsync will not re-create the hardlinked file "a" but
will create a new copy of "a" in the "current" directory.

If "current" is removed and re-created:

rm -rf current
rsync -vaH --delete --numeric-ids -x --link-dest=/tmp/rsync/3/ /tmp/rsync/3/ /tmp/rsync/current/

both files "a" and "b" are hardlinks pointing to the 3rd image.

Robert Sander

More information about the rsync mailing list