Linux Exclude directory in tar and zip

I figured it out. It turns out the GNU Tar which I have as I use Ubuntu requires that the path to be tar’d come after the exclude options. The example listed here had it before.

TAR:

tar -cvf httpdocs_06_20_2006.tar.gz 
/home/user/domain.com/site
--exclude "/home/user/domain.com/site/excluded-dir1" 
--exclude "/home/user/domain.com/site/excluded-dir2"

GNU TAR:

tar -cvf httpdocs_06_20_2006.tar.gz 
--exclude "/home/user/domain.com/site/excluded-dir1" 
--exclude "/home/user/domain.com/site/excluded-dir2"
/home/user/domain.com/site

Leave a comment