Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5467
  • Last Modified:

tar --exclude

I want to tar up a large directory.
I want to exclude some specific archive sub-directories and previous application release sub-directories.
My company does not allow open source tools like gnu tar, which I beieve has an --exclude option to tar.
How  is the best way to exclude specific sub-directories when making a tar of a directory.
Thanks for your help!
0
theoradically
Asked:
theoradically
  • 2
  • 2
  • 2
  • +4
2 Solutions
 
TintinCommented:
<rant>
If your company doesn't allow open source tools, then they will have to get rid of Solaris now that it has gone open source
</rant>

What version of Solaris do you run?

In Solaris 9 at least, you have the -X option to specify a file exclude list.
0
 
PsiCopCommented:
Allow me to echo Tintin's rant. Modern Solaris, starting with v8 and especially v10, is loaded with F/OSS tools. Examples include the zlib compression library, OpenSSH, OpenSSL, gzip, bash, Apache and I'm sure more that I can't think of right this second. Guess the inmates are running the place where you are.
0
 
Nisus091197Commented:
Hi all,

The -X option is available in Solaris 2.6.

You could also use find to exclude filename like this:

find /tmp ! -name 'banana*'

Hope this helps,

Regards, Nisus
http://www.omnimodo.com
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!

 
theoradicallyAuthor Commented:
OK,

So, I created a file called Exclude, and put the directories that I wanted excluded in that file
then ran

tar cvfX ted.tar ./* Exclude

to create a tar file called ted.tar that excluded directories listed in the file called Exclude
Thanks for your help
0
 
theoradicallyAuthor Commented:
OK, my comment above worked on a Solaris 9 test box, but then when I went on to my
production Solaris 8 box, the

tar cvfX ted.tar ./* Exclude

format did not work.  It did not exclude the dirs in the Exclude file.
I listed them as relative path and then tried full path.
Any suggestions
0
 
macker-Commented:
Compile GNU tar and don't tell anyone?

That or explain to the company that by not allowing you to use common and standard tools, for which there is no licensing restrictions, costs, or practical IP concerns, that your productivity will be greatly reduced and you'll have to spend a good deal of time re-inventing the wheel.

If you don't believe they'll listen to reason, then I would seriously consider the use of GNU tools under a don't-ask-don't-tell model.  Linux has been used in that style in enterprise for a long time now.  Even Microsoft has had Linux boxes on their network  (linux.microsoft.com I believe, which presumably was there for testing, which was running RedHat Linux and was reachable by telnet from the outside world for about 5 hours...)

It might be possible to use tar from a newer version of Solaris, static compiled if necessary.
0
 
TintinCommented:
Try

tar cvfX ted.tar Exclude .

0
 
neteducationCommented:
Syntax is

    /usr/sbin/tar c [ bBefFhilvwX [ 0-7 ]] [ device ] [ block ]
          [ exclude-filename ... ] [ -I include-filename ]
          filename ...  [ -C directory filename ]

So I would say instead of

# tar cvfX ted.tar ./* Exclude

You should go for

# tar cvfX ted.tar Exclude ./*

Also important could be:


 When using r,u,x, orX, the named files must match exactly to
     the  corresponding  files  in  the tarfile.  For example, to
     extract ./filename, you must  specify  ./filename,  and  not
     filename.  The t option displays how each file was archived.

0
 
neteducationCommented:
oops... tintin already suggested this... diddn't want to steal points :-))
0
 
Hanno P.S.IT Consultant and Infrastructure ArchitectCommented:
Yes, the directory (files) to be backed up is always last in the command ;-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now