Solved

tar Directory Exclude

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
Window placement 17 83
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 255
"Black Box" Testing of Control System Software 2 51
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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