Solved

tar Directory Exclude

Posted on 1997-05-13
3
3,055 Views
Last Modified: 2013-12-26
I'm writing a backup routine to .tar the contents of selected
directories.  That's the easy part.  Here's the problem.
I was to EXCLUDE the directory 'logs' from all the selected
directories to tar.

So say I tar recursively from my root directory using the "*"
wildcard. That would tar everything.  But I want to exclude any
directories called 'logs', but sill tar recursively from the root.

Somebody suggested this so far, but it did't work, here's
my comments about it.

>find -type d -name logs -print > exclude_this
>tar cvXf exclude_this backup_filename *

I don't think this works.  The first line does give
me a list of all the 'logs' directories. But the tar line doesn't seem
to work.  As far as I can tell, tar doesn't have an 'exclude' option,
thus the file 'exclude_this' was ignored and everything was tar'ed
anyway.


Any Ideas? Thanks!

Chris
0
Comment
Question by:mav
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
jos010697 earned 100 total points
ID: 1292837
Don't you hate those different tar implementations ... I bet
you're running an AIX machine. If your tar supports it,
you could use the -L flag though, indicating whicht files
to include in the tar archive. The -L flag needs a file
as its argument. The file contains the names of the files
to include in the tar archive. Build the include file as follows:

find . -name log -prune -o -print > include_this

build the tar archive as follows:

tar cvLf include_this backup_filename

kind regards,

Jos


0
 
LVL 1

Expert Comment

by:leendert
ID: 1292838
Hi there,

alternatively you can use zip / unzip for backup purposes. This
will compress the files while creating one big file.

To exclude the log directories you would use it like this :

zip -r <Dest_file> <Source Dirs> -x log

This will exclude all the log directories from the zip file
created.  You can then use tar to put the .zip files on a tape.

Hope this will help you...

Leendert.

0
 
LVL 1

Expert Comment

by:leendert
ID: 1292839
Hi there,

alternatively you can use zip / unzip for backup purposes. This
will compress the files while creating one big file.

To exclude the log directories you would use it like this :

zip -r <Dest_file> <Source Dirs> -x log

This will exclude all the log directories from the zip file
created.  You can then use tar to put the .zip files on a tape.

The sources for zip and unzip can be found anywhere on the WEB.

Hope this will help you...

Leendert.

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to determine file rename from EventLog ? 2 36
format the code in java 6 72
countEvens challenge 2 58
wordmultiple challenge 12 90
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now