LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-18-2010, 08:45 PM   #1
jimdeadlock
LQ Newbie
 
Registered: Aug 2010
Distribution: Ubuntu 10.4
Posts: 3

Rep: Reputation: 0
tar and symbolic links


I'm backing up my whole system to an external hard drive using tar and for the most part it works like a charm. However, I'm having trouble extracting symbolic links from the tarball, they are restored as empty files without any permissions or original ownership:

Code:
$ ls -l /home/jim/mysymlink
lrwxrwxrwx 1 jim  jim     22 2010-08-19 00:18 /home/jim/mysymlink -> /media/Maxtor/mysymlink

$ sudo tar cfpz /media/Maxtor/backup1.tgz --exclude=/media/Maxtor /

$ sudo tar xfpz /media/Maxtor/backup1.tgz home/jim/mysymlink

$ ls -l /home/jim/mysymlink
---------- 1 root root     0 2010-08-19 00:19 /home/jim/mysymlink
All other files can be extracted properly with correct ownership/permissions, it's only symbolic links I'm having the problem with. Any ideas?
 
Old 08-19-2010, 01:37 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Well if you exclude the symlink destination, what else is supposed to happen ?
 
Old 08-19-2010, 01:47 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If the target of the symbolic link is under the base directory being archived and is also archived, then the symbolic link will be restored correctly. Look at the tar info file and search for "symbolic".
 
Old 08-19-2010, 02:27 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Actually GNU tar preserves symbolic links, even if the target file does not exist anymore. Which version of tar are you running?
Code:
tar --version
 
Old 08-19-2010, 11:52 AM   #5
jimdeadlock
LQ Newbie
 
Registered: Aug 2010
Distribution: Ubuntu 10.4
Posts: 3

Original Poster
Rep: Reputation: 0
@smoker - the exclusion was for my external hard disk when creating the archive, the symlinks are on my computer. They were included in the archive but it's when I try to extract them I'm having the problem.

@jschiwal - these requirements are all met and it's still not working properly

@colucix - I'm running Tar 1.22 on Ubuntu 10.10 (lucid)
 
Old 08-19-2010, 01:20 PM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
If the symlinks were in the archive, then when you extracted the archive, presumably as root, it merely copied the archive contents over the existing symlinks. But the links in the archive were broken when you excluded /media/Maxtor - hence the current situation. Tar can follow symlinks if you tell it to, but you didn't and you excluded the destination anyway.

IMHO anyway ...

Have you tried testing with a symlink that points at a file that does get archived ?
 
1 members found this post helpful.
Old 08-19-2010, 03:21 PM   #7
jimdeadlock
LQ Newbie
 
Registered: Aug 2010
Distribution: Ubuntu 10.4
Posts: 3

Original Poster
Rep: Reputation: 0
Ahh yes that makes perfect sense now you've explained it and you're correct, other symlinks on the filesystem are extracting properly. Thanks so much!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Symbolic links Vs Hard links sulekha Linux - General 2 10-02-2008 07:03 AM
tar and symbolic links cbriscoejr Linux - General 1 03-18-2005 05:45 PM
tar overwriting symbolic links lapthorn Linux - General 1 03-18-2005 01:25 PM
tar wont work: Cannot exec: Too many levels of symbolic links abefroman Fedora - Installation 3 09-25-2004 02:54 PM
Symbolic links bkmesenbrink Linux - Newbie 2 11-13-2002 11:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration