Friday, November 8, 2013

tar gzip exclude folder

Rule n.1:

never run tar inside the same folder you are tarring: tar will include the tar-file that it's creating... CRAZY!

Rule n. 2:

--exclude works only if it's the first parameter after tar... IN SOME versions of tar ONLY.... CRAZY!
in my version it has to come last.
cd /opt/oracle/backups
tar cvzf osbpr1dobackup11Nov2013_108.tar.gz /opt/oracle/domains/osbpr1do/ --exclude="shared/store/jms"


Rule n. 3:

if the exclude folder ends in /, tar will ignore it without warning.... CRAZY!

Rule n. 4:

The exclude parameter shoule be relative to the -C path:

this is good:

tar cvzf /opt/oracle/backups/deleteme.tar.gz -C /opt/oracle/bin/ . --exclude="src"

this is bad:

tar cvzf /opt/oracle/backups/deleteme.tar.gz -C /opt/oracle/bin/ . --exclude="/opt/oracle/bin/src"

That's why I never use tar but rather jar.

No comments: