Skip to contentSkip to conversation

Tar Exclude

DISCUSSION Paul Kraus 3 participants 4 messages Nov 13, 2002

lore
Share & tools
lore

Paul Kraus

author
#0 lore raw

When running tar with the exclude set tar creates a 10k empty tar file.

I have a script that tars a all the sub directories of a directory into individual tar files for each subdirectory. I have an exclude file that is set to skip some of the folders I don't want tarred. This works but it creates the empty tar files. Is this normal? Can it be set not to do this?

Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com

BEGIN:VCARD
VERSION:2.1
N:Kraus;Paul
FN:Paul Kraus ([email protected])
ORG:PEL Supply Company
TITLE:Network Administrator
TEL;WORK;VOICE:(216) 267-5775
TEL;CELL;VOICE:(216) 410-5526
TEL;WORK;FAX:(216) 267-6176
ADR;WORK:;;4666 Manufacturing Road;Cleveland;Ohio;44135;United States of America LABEL;WORK;ENCODING=QUOTED-PRINTABLE:4666 Manufacturing Road=0D=0ACleveland, Ohio 44135=0D=0AUnited States of Ame= rica
ADR;HOME:;;;;;;United States
LABEL;HOME:United States
URL;WORK:http://www.pelsupply.com
EMAIL;PREF;INTERNET:[email protected]
REV:20020416T182124Z
END:VCARD

#1 lore raw
Quoted 7 lines · Paul Kraus

When running tar with the exclude set tar creates a 10k empty tar file.

I have a script that tars a all the sub directories of a directory into individual tar files for each subdirectory. I have an exclude file that is set to skip some of the folders I don't want tarred. This works but it creates the empty tar files. Is this normal? Can it be set not to do this?

How about showing us the line out of the script that calls tar, and a sample of your exclude line. Tar can be... tempermental when it comes to exclude's.

Mike

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

author
#2 lore raw

Here is the script
------------------
exceptions=/backup/scripts/archive.exclude

        dt=`date +%A`
        cd /backup
        for filestotar in `ls --almost-all --directory -x1 *`
        do
                tar --directory /backup/tar.archive \
                    --create --verbose  \
                    --exclude-from $exceptions \
                    --file /backup/tmp/$filestotar.$dt.tar \
                    /backup/$filestotar/* 1>

/backup/tmp/$filestotar.$dt.index
done

-----Original Message-----
From: Mike Dresser [mailto:[email protected]]
Sent: Wednesday, November 13, 2002 10:22 AM
To: Paul Kraus
Cc: [email protected]
Subject: Re: Tar Exclude

Quoted 9 lines · Paul Kraus

When running tar with the exclude set tar creates a 10k empty tar file.

I have a script that tars a all the sub directories of a directory into individual tar files for each subdirectory. I have an exclude file that is set to skip some of the folders I don't want tarred. This

works but it creates the empty tar files. Is this normal? Can it be set not to do this?

How about showing us the line out of the script that calls tar, and a sample of your exclude line. Tar can be... tempermental when it comes to exclude's.

Mike

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#3 lore raw
In reply to Paul Kraus
Quoted 4 lines

I have a script that tars a all the sub directories of a directory into individual tar files for each subdirectory. I have an exclude file that is set to skip some of the folders I don't want tarred. This works but it creates the empty tar files. Is this normal?

Yes. It is, in fact, exactly what you've told tar to do: create a tar file containg everything in directory foo, excluding files in directory foo. This gives us an empty tar file.

Quoted 1 line

Can it be set not to do this?

I can't see any immediately obvious way to stop tar making empty files, but you could try a script like this:

tar --create ... # Whatever arguments you're currently using for tar. [ tar -tf foo.tar | wc -l -eq 0 ] && rm foo.tar

replacing foo.tar with the filename of the generated tarball which might be empty. (The second line checks whether the tar file is empty, and rm-s it if it is).

This isn't a terribly pleasant solution, but it should work.

Steven Smith,
[email protected].