1

I would like to archive some directories. These directories are contain some softlinks. I should keep these links and files, too.

I didn't found any solution... I tried tar with -h option but it keeps just files, but not links. The simple -cf neither.

2
  • Your question is not clear. tar archives all files including symlinks by default, and -h makes it archive symlinks' targets instead of the symlinks, so by a process of elimination I guess you want to archive both symlinks and their targets. Is that it? Commented Jan 13, 2015 at 23:10
  • Sorry for my mistakes... 1st of all... my english is poor. 2nd I never learned programming... I'm quite newbie in coding and it seems sometimes harder to ask a question, like find the right answer. I'm sorry and thank you for your time. Commented Jul 26, 2017 at 8:55

2 Answers 2

3

Symbolic links are pointers to files in a filesystem. You may want to try to use the --dereference option with tar.

This asks tar to create copies of the data that the symbolic links point to.

Here is the documentation from gnu.org

When `--dereference' (`-h') is used with `--create' (`-c'), tar archives the files symbolic links point to, instead of the links themselves. 
0
0

You need to create the symlinks on the target machine manually in this case.

On the source machine use tar cvhf (or czvhf). when extracting on the target, the files find their way to the right location, if the symlinks exist.

If they do not exist, tar the symlinks separately with tar cvf and extract on the target before extracting the rest of the files, archived with tar cvhf.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.