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
Solved

Exclude files/directores while tar extraction

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

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

861 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