Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exclude files/directores while tar extraction

Posted on 2010-11-22
5
Medium Priority
?
1,032 Views
Last Modified: 2012-05-10
I used "tar -cvzf clone.tgz /" to backup the root directory '/' on my ubuntu 9.10 server. Now I want to extract it on a newly installed machine. How could I exclude files and directories while tar extraction.
For extraction I'll be using "tar -xvpzf clone.tgz -C /" which overwrites all the files and directories.

Let say I want to exclude the directory '/etc/udev/' and a file '/home/file1' while Extracting the tar file. Is it possible to do so?
0
Comment
Question by:Thyagaraj03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 1000 total points
ID: 34194402
Use exclude.
tar -xvpzf clone.tgz --exclude "/etc/udev" --exclude "/home/file1" -C /

Open in new window

0
 

Author Comment

by:Thyagaraj03
ID: 34194698
For checking, I created tar of  /etc/ and /home and tried to extract on a directory called 'test' with the following command:

tar -xvpzf clone.tgz --exclude "/etc/udev" --exclude "/home/file1" -C /test/

The 'test' directory has the udev dir. and the file1 in the respective directories. What I'm doing wrong?.
0
 
LVL 16

Assisted Solution

by:Blaz
Blaz earned 1000 total points
ID: 34195304
Try removing leading /

tar -xvpzf clone.tgz --exclude "etc/udev" --exclude "home/file1" -C /test/

0
 
LVL 23

Expert Comment

by:Maciej S
ID: 34195485
Post output of "tar ztf clone.tgz" command.
0
 

Author Comment

by:Thyagaraj03
ID: 34202592
Thanks a lot!. Blaz made a small change and it worked.
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question