如何从符号链接创建备份?

hkn*_*nik 77 tar symlink

我有一个带有指向其他目录的符号链接的目录。我想使用 tar 命令归档符号链接,而不是作为链接,而是作为包含它们引用的目录文件的档案。我怎样才能做到这一点?

Mat*_*Mat 120

使用-htar 选项。从手册页:

-h, --dereference
    don't archive symlinks; archive the files they point to
Run Code Online (Sandbox Code Playgroud)

  • 如果我有 /sym1 指向 /backups 而 /sym2 指向 /backups,那么我运行 `tar -hcf file.tar /sym1 /sym2` 会得到两次 /backups 吗? (4认同)
  • 选项的顺序很重要。即`tar -czfvh`将失败`tar -hczfv`将工作 (2认同)