Is there a way (in several commands if necessary) to make a tar
archive that follows all the symlinks (like with tar -h
) except for one recursive symlink, which should be preserved as it is?
I have a directory structure like this:
project1
code folder
dependencies folder
symlink to project1 folder (recursive!)
symlink to project2 folder
symlink to project3 folder
... more symlinks, folders, etc
project2
code folder
project3
code folder
... more projects
I want to tar
project1
and have it follow all the symlinks to copy external folders like project2
and project3
, but I do not want it to follow the recursive symlink it has to itself because it's not necessary and it causes tar
to run forever.
From the man
page it looks like I can do this with tar -H
but I will have to specify every symlink I want to follow. That is a long list and requires updating any time I add another symlinked dependency, so I am looking for a solution that works with less maintenance.
The quick answer here is "don't use recursive symlinks" and that is what I am doing for now, but it is something I would like to have for my project and I can't do it without coming up with a solution to this problem.