Solved

Exclude files/directores while tar extraction

Posted on 2010-11-22
5
1,011 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
  • 2
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 250 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 250 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now