Solved

Exclude files/directores while tar extraction

Posted on 2010-11-22
5
1,015 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

831 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