LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2009, 03:06 PM   #1
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Rep: Reputation: 30
untar backup into new directory? absolute paths in tar


Hi
My backup is stored with absolute paths inside it, eg
/etc/sysconfig
/etc/squid

Is there a way to untar it into a new directory without the contents untarring themselves to the actual /etc directories?
I will move individual files later.
 
Old 08-19-2009, 03:22 PM   #2
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Try using -C /path/newdir when extracting. A simplistic example:
Code:
tar xvzf test.tgz -C /tmp/test
 
Old 08-19-2009, 03:31 PM   #3
Nevahre
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Rep: Reputation: 16
tar xzf test.tgz alone works (first copy to safe directory, say /tmp). You also need to include the P to extract absolute. Very wise tar safety!

Checked with:
$ tar --version
tar (GNU tar) 1.15.1
and works.
 
Old 08-19-2009, 03:37 PM   #4
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Quote:
tar xzf test.tgz alone works
If you want the added step of copying. One command to accomplish two works just fine for me.
 
Old 08-19-2009, 03:41 PM   #5
Nevahre
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Rep: Reputation: 16
And the other works fine for me
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to untar all tar-files in a directory? zoomzoom Linux - Newbie 13 05-09-2017 11:52 AM
Absolute and relative paths Gins Linux - General 6 11-08-2008 08:48 PM
Untar a particular directory from a tar.gz? nyheat Linux - Newbie 5 05-09-2008 09:01 AM
tar backup of an XP directory fof3 Linux - Newbie 2 03-31-2007 03:39 PM
relative/absolute paths in Java djgerbavore Programming 2 10-26-2004 08:01 PM


All times are GMT -5. The time now is 07:53 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration