简体   繁体   中英

Zip folder exclude some folders

I'm trying to backup my www-folder but hidden folders like .config inside www are added to the backup. I want to exclude the folder "backups" and all folders (and files) starting with a dot.

The problem is that it copies all the hidden folders like .config to the zip-file.

Current code:

zip -r /var/www/backups/site/$(date +\%Y-\%m-\%d-\%H-\%M).zip /var/www -x "*backups*" "*.*" "*/.*"

这应该为您工作。

zip -r --exclude=*backups* --exclude=*/.* /var/www/backups/site/$(date +\%Y-\%m-\%d-\%H-\%M).zip /var/www

Use a linux find command with an exclude flag, then pipe it into zip.

The following command will exclude all paths under the current directory containing the keywords "backups" or files with "/." in the path and then pipe the files into zip.

    find . | grep -v "\(backups\|/\.\)" | xargs zip archive.zip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM