--link-dest / --hard-links problem

Raphael Jaffey rjaffey at artic.edu
Sat Apr 23 19:01:38 GMT 2005


I've looked around for a bug report on this problem and haven't seen one, so I
apologize if this has already been discussed.

I have a homegrown script which uses rsync to maintain daily backups of roughly
twenty Redhat Linux systems running RH 7.2, 7.3, AS 3, and AS 4.  As there are
files with multiple links on the source systems, it is necessary to call rsync
using the -H (--hard-links) option to maintain accurate backups.  The backup
script uses --link-dest to create daily snapshots of each system where all
unchanged files from a particular system share storage across all backup
snapshots for that system, i.e. if a file hasn't changed as far as rsync is
concerned, it only exists once in the backup server's filesystem, but is linked
to a directory entry in every snapshot.  This works fine provided the file(s)
aren't linked more than once in the source system.  When files are linked
multiple times in the source, not all of the links wind up in the snapshot.

This can be easily reproduced locally with the following example:

########################################################################

[rjaffey at shadow tmp]$ rsync --version
rsync  version 2.6.4  protocol version 29
Copyright (C) 1996-2005 by Andrew Tridgell and others
<http://rsync.samba.org/>
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles, 
              inplace, IPv6, 64-bit system inums, 64-bit internal inums

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

[rjaffey at shadow tmp]$ cat /etc/redhat-release 
Red Hat Linux release 7.3 (Valhalla)
[rjaffey at shadow tmp]$ 


[rjaffey at shadow tmp]$ mkdir from to-1 to-2
[rjaffey at shadow tmp]$ touch from/a
[rjaffey at shadow tmp]$ ln from/a from/b



[rjaffey at shadow tmp]$ rsync -avH from/ to-1/
building file list ... done
./
b
a => b

sent 168 bytes  received 56 bytes  448.00 bytes/sec
total size is 0  speedup is 0.00


[rjaffey at shadow tmp]$ ls -l to-1
total 0
-rw-rw-r--    2 rjaffey  rjaffey         0 Apr 23 13:40 a
-rw-rw-r--    2 rjaffey  rjaffey         0 Apr 23 13:40 b

# Notice that the links were properly preserved in the to-1 directory (first
snapshot).





[rjaffey at shadow tmp]$ rsync -avH --link-dest=/tmp/to-1/ from/ to-2/
building file list ... done
./

sent 118 bytes  received 26 bytes  288.00 bytes/sec
total size is 0  speedup is 0.00

[rjaffey at shadow tmp]$ ls -l to-2
total 0
-rw-rw-r--    3 rjaffey  rjaffey         0 Apr 23 13:40 a


# Notice only one of the links was created, the other one is simply not there.





[rjaffey at shadow tmp]$ rsync -avH --link-dest=/tmp/to-1/ from/ to-2/
building file list ... done
b => a

sent 120 bytes  received 28 bytes  296.00 bytes/sec
total size is 0  speedup is 0.00

[rjaffey at shadow tmp]$ ls -l to-2
total 0
-rw-rw-r--    4 rjaffey  rjaffey         0 Apr 23 13:40 a
-rw-rw-r--    4 rjaffey  rjaffey         0 Apr 23 13:40 b
[rjaffey at shadow tmp]$

# Notice that if I run exactly the same rsync command a second time, the second
link is created.

###############################################################################

The actual rsync command used to do the backups is a little more extensive, but
the same behavior occurs.

Am I missing something here, or is this really a bug?

Thanks,
Rafe


More information about the rsync mailing list