?
Solved

AIX 5.2 tar -X to exclude a directory

Posted on 2009-05-17
10
Medium Priority
?
6,118 Views
Last Modified: 2013-11-17
Hi,
I would like to exclude a directory from my tar of /usr/sap/trans backup.
i have tried using the -X option (as specified in the man pages), but the option is not recognised when it is in the command.
The command I am trying to run is:
tar -cvf trans.tar /usr/sap/trans -X /usr/sap/trans/<dir_to_exclude>
The system does not like the -X option.

Any ideas?
Cheers,
ShamelessUK
0
Comment
Question by:Shamelessuk
[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
10 Comments
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 900 total points
ID: 24405915
Hi,

The correct syntax would be:

tar -cvf trans.tar -X /usr/sap/trans/dir_to_excl /usr/sap/trans

All the switches must be specified before backup lists. It should work this way.

Cheers,
K.

0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 900 total points
ID: 24405919
Don't forgeet that -X can contain only one file or directory at a time an you can specify multiple occurences of -X and the -X switch has a precedence over all the other commands and will be processed first.

Cheers,
K.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24405954
Hi ShamelessUK,
you're right, tar as shipped with AIX 5.2 doesn't honour the -X option.

How about upgrading to 5.3?

OK, seriously,  you can use the tar  contained in the AIX toolbox or here -

http://www.perzl.org/aix/index.php?n=Main.Tar

Download it, install using 'rpm -i tar-1.22-1.aix5.1.ppc.rpm'

and call it by '/opt/freeware/bin/tar ......'  with the remaining parameters as in your Q.

If, for some reason, there was no possibility for you to install that tar version, we could construct an 'include' file, use of which is supported with your tar.
For that construction we need to know your exclusion criteria. Perhaps we can then work out something useful.

Good luck!

wmp


 

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 900 total points
ID: 24405962
In fact I guess there's a need for clarification. -X excludes a list of files and directories and the parameter to -X is not an expression but a filename. So in the above example by me:
/usr/sap/trans/dir_to_excl is not a directory name it is a filename and it contains the names and paths of files and directories one at a line.

It is only the GNU tar that could exclude expressions from the command line.

so if you create a filename /usr/sap/trans/dir_to_excl and place this line in it such as this one:
/usr/sap/trans/dir_to_excl
/usr/sap/trans/file1      (assumenf that there's a file caleld file1 in the directory)

The tared contents will not include these files.

Cheers,
K.

0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24405986
@woolmilkporc:

> Hi ShamelessUK,
> you're right, tar as shipped with AIX 5.2 doesn't honour the -X option.

I am afraid this is not correct. -X option is supported by AIX V 5.2 an up. Furthermore if it did not accept the switch it would print a nag line such as:

tar: illegal option -- X

0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 100 total points
ID: 24407060
AIX uses POSIX compliant tar without gnu extensions.
You can create file list using find, grep out wrong folders and pass to tar.

find / -type f -print | grep -v /bad/folder | xargs tar cf /tmp/data.tar
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24407201
Will you post the output of tar command (I mean the usage info when you type just tar on a line)? also the output of oslevel -r ?

Should be similar to this:
Usage: tar -{c|r|t|u|x} [ -BdDEFhilmopRsUvw ] [ -Number ] [ -f TarFile ]
           [ -b Blocks ] [ -S [ Feet ] | [ Feet@Density ] | [ Blocksb ] ]
           [ -L InputList ] [-X ExcludeFile] [ -N Blocks ] [ -C Directory ] File ...
Usage: tar {c|r|t|u|x} [ bBdDEfFhilLXmNopRsSUvw[0-9] ]
           [ Blocks ] [ TarFile ] [ InputList ] [ ExcludeFile ]
           [ [ Feet ] | [ Feet@Density ] | [ Blocksb ] ] [-C Directory ] File ...

0
 
LVL 62

Expert Comment

by:gheist
ID: 24407236
0
 

Author Closing Comment

by:Shamelessuk
ID: 31582347
Thanks guys.  I had to tar individual directories in the end as it was a customer system and they removed my root access shortly after I posted the question - thus killing my attempts to try out the solutions suggested.  That said, I have tried them out on a different machine and all seemed to work as expected.
Thanks again,
Shamelessuk
0
 
LVL 62

Expert Comment

by:gheist
ID: 24492382
If it goes routine try gnu tar - remember that normal AIX tar will not be able to open files (7-zip or tar on linux/bsd will open them)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

801 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