GagA// 0n D nEt

It is currently Sun May 20, 2018 3:40 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux: tar cannot archive symbolic link
PostPosted: Fri Mar 13, 2009 3:42 am 
Offline

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
You may come across a situation when you had compressed a folder which contains a symbolic link to another file/folder (other than the one being compressed) and when you decompress that file on another machine you end up getting a broken symbolic link in the decompressed data.

The reason for this, well normally when tar archives a symbolic link, it writes a record to the archive naming the target of the link. So you can say that the tar archive is a faithful record of the filesystem contents. So this means that even if you try and create a archive for a symbolically linked file, you won't get the actual data of the file, instead you will be getting a symbolic link reference.

In order to overcome this, you need to use -h flag or --dereference flag along with the -c (--create) flag while creating an archive.

This flag causes tar to archive the files symbolic links point to, instead of the links themselves. When this option is used, and when tar encounters a symbolic link, it will archive the linked-to file, instead of simply recording the presence of a symbolic link.

The name under which the file is stored in the file system is not recorded in the archive. To record both the symbolic link name and the file name in the system, archive the file under both names. If all links were recorded automatically by tar, an extracted file might be linked to a file name that no longer exists in the file system.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group