Does tar preserve links? [duplicate]

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.

2

4 Answers

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

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

GNU tar has options for that

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

It can, depending on the options you do/don't give it. Also, with regard to hard links, it will only preserve the hard links within the data set you are currently working with - e.g. if you have a hard link between a file in directory a/ linking to a file in b/, but you're only archiving/unpacking a/, then it won't preserve that link.

You should try Rsync in this case.

You Might Also Like