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

11

Can you please tell me how can I tar ball/compress a directory hierarchy with soft links in linux?

Thank you.

michael

Posted 2010-05-04T06:47:05.687

Reputation: 4 127

1Do you want the final tarbal to have the soft-links or the target file of those links. It's unclear in your question. – slubman – 2010-05-04T06:51:01.630

Answers

7

GNU tar normally includes symlinks in the tarball it generates. If you want it to include the file the symlink points to instead then pass it -h/--dereference when creating the tarball.

Ignacio Vazquez-Abrams

Posted 2010-05-04T06:47:05.687

Reputation: 100 516

6

When used with standard arguments tar xvf the soft link are saved in the tar archive as soft-links. Then there is 2 cases

  • If your symlink is a full symlink, it might be broken when untarred.
  • If your symlink is a relative symlink, under the folder you are tarring it will work fine when extracted.

If you want to tar the file and not the symlink, you can use the -h / --dereference argument.

slubman

Posted 2010-05-04T06:47:05.687

Reputation: 932