On Tue 28 Aug 2007, Larry Alkoff wrote:
> I have an rsync cron script that copies one entire hard drive containing
> hard links to another drive. It does this by selecting the directories
> to be rsync'ed and copying them one by one.
>
> My rsync line is:
> rsync -uav source/ target
> and the problem is this would not copy hard links.
>
> If I change the rsync line to:
> rsync uaHv --delete source/ target
> will the files copied using the original line be deleted and replaced
> with hard links?
The first one encountered won't, but the rest will :-)
$ mkdir from to
$ dd if=/dev/zero of=from/a count=20
20+0 records in
20+0 records out
10240 bytes (10 kB) copied, 0.000276 seconds, 37.1 MB/s
$ ln from/a from/b
$ rsync -av from/ to
building file list ... done
./
a
b
sent 20671 bytes received 70 bytes 41482.00 bytes/sec
total size is 20480 speedup is 0.99
$ ls -li to
total 24
149983 -rw-r--r-- 1 paul staff 10240 Aug 28 18:29 a
149987 -rw-r--r-- 1 paul staff 10240 Aug 28 18:29 b
$ rsync -avH from/ to
building file list ... done
b => a
sent 115 bytes received 28 bytes 286.00 bytes/sec
total size is 20480 speedup is 143.22
$ ls -li to
total 24
149983 -rw-r--r-- 2 paul staff 10240 Aug 28 18:29 a
149983 -rw-r--r-- 2 paul staff 10240 Aug 28 18:29 b
Note the inode number of the first file (to/a) doesn't change, the
second file becomes linked to that one.
Paul Slootman