Consider this test case:
mkdir a echo 'blah' > a/test mkdir b echo 'blah' > b/test rsync -r --link-dest=/tmp/b /tmp/a/ /tmp/c
As expected, rsync creates
c/test a hardlink of
b/test (note the refcount of
# ls -l c/test -rw-r--r-- 2 root root 16 Jan 6 19:43 test
Now see this:
rm -r c # start over touch b/test rsync -r --link-dest=/tmp/b /tmp/a/ /tmp/c
The hardlink is not created:
# ls -l c/test -rw-r--r-- 1 root root 16 Jan 6 19:50 test
The manpages says (emphasis mine):
The files must be identical in all preserved attributes (e.g. permissions, possibly ownership) in order for the files to be linked together.
However, I think that by default the filetime is not preserved and should therefore make no difference here.
What is happening? Is this a bug? What can I do?
My goal is to save space on a continuous integration server that hosts many branches of a repository by hard-linking all the identical files. So my actual command is:
rsync -r --link-dest=/ci/master /ci-runner/build/ /ci/branch-123.
This means I don't care about the times, so I thought about
touching them all to the current time before the
rsync but it would be a somehow crude solution and also touch does not seem to work recursively.