I have a large remote directory A
and local directory B
that are nearly identical in content, though many of the modification times may have changed by copying files etc. I want to create a local directory C
with identical content to A
, hard-linking to files in B
whenever the content is the same. I don't care about getting the modification times the same.
Is this possible with rsync
?
For a test case, I have the following local setup (I assume the behavior won't change when A
is on a remote server):
[Compputer:/tmp] % cat A/a B/a
foo
foo
[Compputer:/tmp] % rsync -rIv --link-dest=$PWD/B/ /tmp/A/ /tmp/C
building file list ... done
created directory /tmp/C
./
a
b
sent 169 bytes received 71 bytes 480.00 bytes/sec
total size is 8 speedup is 0.03
[Compputer:/tmp] % ls -lT A B C
A:
total 16
-rw-r--r-- 1 ken wheel 4 May 28 00:01:15 2016 a
-rw-r--r-- 1 ken wheel 4 May 28 00:01:22 2016 b
B:
total 8
-rw-r--r-- 1 ken wheel 4 May 28 00:01:34 2016 a
C:
total 16
-rw-r--r-- 1 ken wheel 4 May 28 20:46:31 2016 a
-rw-r--r-- 1 ken wheel 4 May 28 20:46:31 2016 b
Notice that a
isn't hardlinked.
rsync
questions on Server Fault than the other sites. Please propose a move if appropriate.