Solved

tar Directory Exclude

Posted on 1997-05-13
3
3,117 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

726 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