How to use 7-zip to backup files, but exclude some directories

7-zipbackupcommand line

I would like to use 7-zip to backup a directory, but I would like it to exclude all directories named ".svn" (anywhere in the source tree). Does anybody know if this is possible and in that case how?

Best Answer

To exclude all .svn directories you need to add the -xr!?svn\* switch

For example the following will create a backup of the C:\Project\To\Backup directory excluding any folders that satisfy ?svn:

"C:\Program Files\7-Zip\7z.exe" a -r -tzip -y -xr!?svn\* Project.zip C:\Project\To\Backup\*
Related Question