11

I've got a bash script that does something like this:

zip -0 ../backup/backup.zip \
-r ./* \
-x \*CVS\* \
-x *Thumbs.db* \

The directory it's backing up is a SVN archive (it used to be CVS back in the day). I've been unable to get it to exclude .svn and it's contents. What's the cleanest way to exclude .svn (recursively through the entire tree)?

2 Answers 2

8
zip -0 ../backup/backup.zip -r . -x "*CVS*" "*Thumbs.db*" "*.svn*"

-x also accepts a list of excludes.

Alternatively, create a filelist with your excludes and add them there.
The exclude.lst:

*CVS*
*Thumbs.db*
*.svn*
exclude.lst

with the command:

zip -0 ../backup/backup.zip -r . -x@exclude.lst
1
  • -x "*CVS*" excludes any file or directory whose name contains CVS as a substring (ditto for .svn). Jan 27, 2011 at 19:16
2
zip ../backup/backup.zip \
  -x '/CVS/*' -x '*/CVS/*' \
  -x '/.svn/*' -x '*/.svn/*' \
  -x '/Thumbs.db' -x '*/Thumbs.db' \
  -r .

Note that your exclude patterns as posted aren't quite right, they exclude any file or directory whose name contains CVS.

You must log in to answer this question.