[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

tar command exclude  question

Posted on 2011-05-12
13
Medium Priority
?
522 Views
Last Modified: 2012-05-11
I'm trying to restore  /etc/ directory and wants to exclude  /etc/pki directory and some  other files. The follwoing command is not working. Do I need to do anything else?

tar  xpvfz  backup_opt.tgz  -C  /  --exclude=/etc/pki/
0
Comment
Question by:mokkan
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 892 total points
ID: 35751489
Are you trying to create tar ?

You can using x, which means you are extracting tar.

To create tar you need option c

tar pcvfz  backup_opt.tgz  -C  /  --exclude=/etc/pki/
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35751498
Also you can have as many excludes as you want -- while creating the tar.  If you have a tar and you want to delete files from it that is different.  Please tell me what you want

0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 888 total points
ID: 35751507
mkdir /etc_tmp
tar  xpvfz  backup_opt.tgz  -C /etc_tmp
rm -rf /etc_tmp/etc/pki
cp -pr /etc_tmp/etc  /
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 892 total points
ID: 35751519
tar  cpvfz  backup_etc.tgz  /etc --exclude=/etc/pki/

You don't need -C in creation.  But you do need to mention the folder you want to tar!!

You would need -C when you extract if you did not create with -P (upper case P) option.
0
 

Author Comment

by:mokkan
ID: 35751562
I want to do

cp  -ar  *  /etc  

but, it is prompting and I need to say yes all the time. How do I force it to overwrite?
0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 888 total points
ID: 35751568
/bin/cp -afpr * /etc/
-f force
/bin/cp to avoid alias
0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 888 total points
ID: 35751570
/bin/cp -afr * /etc/
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 892 total points
ID: 35751587
\cp -far * /etc

I wrote it before but somehow it did not go through
0
 

Author Comment

by:mokkan
ID: 35751604
still same thing I saw   cp  -i in .bashrc file I comment out and I did source .bashrc

still same issue
0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 888 total points
ID: 35751611
You mean
/bin/cp -afr * /etc
or
\cp -far * /etc
still prompt ?
0
 
LVL 20

Assisted Solution

by:simon3270
simon3270 earned 220 total points
ID: 35753227
Just a side comment - if you comment out an alias in .bashrc and simply source it again, the old alias definition is still in place.  Either explicitly "unalias cp", or comment out the line and log out and in again.
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 892 total points
ID: 35753233
\cp unaliases it
0
 

Author Closing Comment

by:mokkan
ID: 35754024
Thanks a lot all of you. It worked fine now. After I logged in back, it  didn't source .bashrc correctly
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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…
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…
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
Course of the Month17 days, 20 hours left to enroll

830 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