Solved

tar Directory Exclude

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 28
How to calculate times for developing software? 8 65
Define unique primary key 9 89
Change to event 1 101
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

21 Experts available now in Live!

Get 1:1 Help Now