备份硬链接(rsync)?

备份硬链接(rsync)?

我的问题始于:我的磁盘上实际上有硬链接吗(当然“.”和“..”除外)?我不知道我该如何发现这一点?

如果不是,则问题已经得到解答。

如果是,我想调整我的备份例程(当前使用rsync -a)以保留我的硬链接。我已经看到了该选项-H,但手册页上的一些陈述让我担心,例如:

-a, --archive
    ...
    Note that  -a  does not preserve hardlinks, because finding 
    multiply-linked files is expensive...

-H, --hard-links 
    ...
    It does NOT currently endeavor to break already existing hard links 
    on the destination that do not exist between the source files. ...

    Note that rsync can only detect hard links between files that are 
    inside the transfer set...

那么,如果我的磁盘上有硬链接,我该怎么办?

答案1

如果您有标准发行版,则硬链接很少,因此您通常不需要太担心。 /binsbin/lib/modules、 以及/usr有一堆硬链接,因此如果您要备份它们,您可能需要使用 -H 选项。备份目录还可能包含硬链接。否则,除非您自己创建硬链接,否则不应有硬链接。

要查找包含硬链接文件的目录,请尝试以下命令(/如果需要,请替换为其他安装点):

sudo find / -xdev ! -links 1 ! -type d | xargs -n 1 dirname | sort -u

相关内容