RSS

Excluding folders when creating a tarball

Wed, Sep 13, 2006

System Administration

When creating a tarball, to exclude folders one simply uses the –exclude= flag:

For example to tar up the contents of /var/log but to exclude /var/log/apache & /var/log/mail/

tar -jcvf logfiles.tar.bz2 /var/log/* --exclude=/var/log/apache/* --exclude=/var/log/mail/*

Just in case you didn’t already know then the ‘j’ flag in the ‘jcvf’ tells tar to use bzip2 compression.

, ,

This post was written by:

Bealers - who has written 352 posts on Darren Beale.


Contact the author

Leave a Reply