In an rsync I am trying to exclude sub-directories that match a pattern. But, I cannot get it to work. I have followed several examples found here and on Google. But, I do not get the correct results. Here is the option bit of my command:
-avh --exclude 'branch*' --stats --delete --link-dest=$LNK
My source directory structure is
/root /branch1 /branch2 /branch3 /other /stillAnother /etc
This is part of a backup script. $LNK is a link to the previous day's rsync destination.
I do not want /root/branch1, /root/branch2, /root/branch3. or their contents to be synced. But, they are.
Here are the exclude bits I have already tried:
--exclude=branch* --exclude='branch*' --exclude '/branch*' --exclude /branch*
Thanks for any help/advice.
EDIT - to address the "possible duplicate" flag
This question is regarding a known list of directories. I need to exclude any directories that follow a pattern, even if those directories do not yet exist. i.e. from my example, other directories named
/branch* may be added. I need to make my script future-proof, and avoid editing the script when a directory that matches the pattern is added, as those directories may be temporary.