Solved

tar Directory Exclude

Posted on 1997-05-13
3
3,111 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
substring method in java 1 141
building a service to accessed via telnet client, want colors ? 4 106
Not needed 13 134
Is there a simple front-end menu system. 9 146
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.

732 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