How to create backup from symbolic links?
90,469
Solution 1
Use the -h
tar option. From the man page:
-h, --dereference
don't archive symlinks; archive the files they point to
Solution 2
If the links are all in the root directory you can have the shell dereference them and pass to tar as arguments. For example if you have /backup/source/a and /backup/source/b, both of which are symlinks pointing to the real directory, something like the following would work
tar -cf /path/to/backup.tar /backup/source/*/
Author by
user1592806
Updated on September 18, 2022Comments
-
user1592806 almost 2 years
I have a directory with symbolic links to other directories. I want to archive the symbolic links, not as links but as archives containing the files of directories they refer to, using tar command. How can I do this?
-
Mcol over 9 yearsIf I have /sym1 points to /backups and /sym2 points to /backups, then I run
tar -hcf file.tar /sym1 /sym2
will I get /backups twice? -
Suuuehgi about 6 years