Monday, June 15, 2009

Exclude directory in tar and zip

OK - 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

Or

tar -zcvf httpdocs_06_20_2006.tar.gz -X a_list_of_exclude_path.txt /home/user/domain.com/site

No comments: