简体   繁体   中英

Exclude sub directories recursively from folder

I have some sub-folders in this path app/static/uploads/

I am expecting that --exclude="uploads" will do the job of ignoring everything in sub-folders. However I am still getting things like app/static/uploads/companies/headers/photo.jpg synced. Any idea how to ignore the sync of everything in the uploads folder?

switches: -vzr  --exclude="uploads" --exclude=".git" --exclude=".github" --exclude=".gitattributes" --exclude=".gitignore"

Your exclude pattern is not regex compliant for your intent.

You would need to do something like the following:

EXCL_DIRS="--exclude='*/uploads/*'"
EXCL_SUFS="--exclude='.git' --exclude='.github' --exclude='.gitattributes' --exclude='.gitignore'"

rsync --recursive --compress --verbose ${EXCL_DIRS} ${EXCL_SUFS}

If all the EXCL_SUFS specifications are to address files under your EXCL_DIRS, then you don't need to define EXCL_SUFS.

It is advisable to use the --dry-run option until you are sure that your command structure will perform as desired (as visually verified by examining the file list reported by rsync).

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