Does tar preserve links?

8,279

Solution 1

Take a look at the man page, at least for gnu tar:

   -h, --dereference
          follow symlinks; archive and dump the files 
          they point to

   --hard-dereference
          follow hard links; archive and dump the files 
          they refer to

Solution 2

generally speaking it depends on tar implementations and command line options.

GNU tar has options for that http://www.gnu.org/software/tar/manual/html_node/hard-links.html

I would like to recommend you use cpio instead of tar. cpio format is more portable across UNIX-es and cpio preserves hard links

Share:
8,279

Related videos on Youtube

Balualways
Author by

Balualways

Linux Enthusiast and explorer, Loves automation and Continuous Delivery, hiking, scripting and vodka

Updated on September 18, 2022

Comments

  • Balualways
    Balualways over 1 year

    Possible Duplicate:
    How can I tar ball a directory hierarchy with soft links in linux

    I am using tar to copy files and directories from a Solaris machine to a Linux machine.

    • Does Tar preserve the Symbolic Links, Hard links and those links which uses absolute paths?

    I am copying the Directories one by one from the root, I am not copying the entire / to the new server as I already have few directories setup.

    • Levon
      Levon over 11 years
      What did you find out when you tried a small example test?
    • jlliagre
      jlliagre over 11 years
      Can you clarify what your expectations are. "preserving links" can be understood different ways, especially referring to "those links which use absolute paths".