By using 7-zip in Linux I need to

  • save zip file to absolute path: /var/www/vhosts/mysite.com/httpdocs/app/webroot/myfiles.7z
  • backup all files and subfolders inside this: /var/www/vhosts/mysite.com/httpdocs/
  • exclude these folders', its subfolders and all files inside them totally: /var/www/vhosts/mysite.com/httpdocs/app/tmp/sessions/ /var/www/vhosts/mysite.com/httpdocs/app/posts/
  • excludes all the files inside these folders, but keep the folder names: /var/www/vhosts/mysite.com/httpdocs/app/news/ /var/www/vhosts/mysite.com/httpdocs/app/handy/
    I mean, zip file will have "news" and "handy" folders, but the folder will be empty

I tried this but didn't help:

# 7za a 

Adding "*" before the exclude expression (and using forward-slashes, this is Linux, right?) helps here:

$ 7za a /var/www/vhosts/mysite.com/httpdocs/app/webroot/myfiles.7z  \
    /var/www/vhosts/mysite.com/httpdocs/ \
    -xr\!*app/tmp/sessions \
    -xr\!*app/posts \
    -xr\!*app/news/* \

There's also 7Zip - Command Line : Exclude folder(s) by wildcard pattern?

| improve this answer | |
  • This worked for me -- 7-Zip [64] 9.20 on Ubuntu 16.04. – treehead Aug 22 '16 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.