Exclude Directories in my tar command

Hi, im having some issues after i execute the next command:

tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz

this creates the desired "test.tar.gz" file, but whe i try to open it it says "tar: 0511-164 There is a media read or write block size error."

My main goal is to tar the directory "jfma" and exclude the subdirectory DWEXPORTS as specified in my excludefile, and then zip it.

This is what my excludefile has:

DWEXPORTS:

The tape archive will be in the file given to the f option. You need to gzip that one, not stdout which will contain a log of tar's actions but no meaningful data. By adding the z option, tar will gzip its output immediately.

And, remove the ":" from your exclude file.

1 Like

Hi, thank you for your quick reply... Thing is im on AIX 6.1 and it doesnt accept the "z" flag. I already removed the ":" from my exclude file though.

Specify a filename of - with -f so that you can pipe the archive itself to gzip .

Regards,
Alister

Sorry Alister, and correct me if im wrong (and i believe i am) but isn't it already -f in my statement?

tar "-cvf"

....

tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz 

If i am wrong how should i establish my statement. Im confused.

thanks again for your time.

tar -cvf - -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz

1 Like

CarloM, thank you i was actually working with:

tar -cvf /varios/restore/test.tar -X excludefile.txt /jfma/test1/

and after that i was going to execute the gzip. Two sentences to be clear, but yours worked for me.

Thank you. God Bless.:b::b::b::b: