I'm trying to use rsync to copy a directory recursively, and copying symlinks referent. I also want to exclude certain directories that are located within the symlink. This is the part that's not working.

I'm using the following command:

rsync -aPL source/ dest/ --exclude source/dir/symlink/node_modules

Directory structure:


Unfortunately, it is still copying the node_modules directory, even though I'm trying to exclude it. Any idea how to do this, if possible?

1 Answer 1


I just realised I don't have to specify the full directory in the exclude, and if I just exclude the node_modules directory by it's name, it works perfectly:

 rsync -aPL source/ dest/ --exclude node_modules

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.