Can rsync preserve hard link across file systems?

1

I'd like to back up my data preserving hard link to a network drive connected through cifs. Is it possible?

My system is Linux (EXT4) and I have two network drives: one is also Linux (EXT4) and the other is Windows. Both are mounted through cifs.

I tried rsync -avzpH but it seemed to work only within a file system. I don't know if I missed an option or it is not possible.

microbe

Posted 2012-03-28T22:09:30.453

Reputation: 111

Hardlinks themselves can't span filesystems, since a file and a hardlink to it share the same inode. If you have a hardlink within a filesystem, the -H option will make rsync copy it.

However, your link is probably a symbolic link, which is copied if you use the -l or -a (which implies -l) switch. You are using the -a switch, so it should copy your symlinks.

tldr: What you're doing should work. – Dr Kitty – 2012-03-28T22:43:03.120

So unlike symbolic links, hardlinks can not be preserved in my backup through rsync if I save it on another drive even though both of the file systems formatted in same format? Did I understand correctly? – microbe – 2012-03-29T14:37:08.580

Answers

2

"and the other is Windows"

The file system on the destination drive also needs to support hardlinks ... only available (by default at least) in vista and later (2k and xp support a similar link type known as junction points, but it doesn't really translate) As long as the file system support is met and rsync is >= 2.5.6, the -H option should take care of hard links (so long as cifs isn't doing something wonky - it can be precarious at times).

technosaurus

Posted 2012-03-28T22:09:30.453

Reputation: 996

It's Windows server 2008. I prefer the hard drive mounted on the Windows because it is bigger but if the file system has a problem to support hardlink, I can use the hard drive mounted on a Linux system formatted EXT4. I'm still not sure if I can preserve hardlinks as I tried -H option. – microbe – 2012-03-29T14:31:36.637