I use rsync as a backup tool to my external hard disk. However I want to save time by no copying useless cache files of several programs. I want to achieve this by omitting every file which is somewhere in the tree under a folder called Cache, cache or cache2 In fact any variations of names which hint to a cache folder in the full path.
They can be in paths like:
.cache/google-chrome/Default/Cache/1e1cb5d5222c54c4_0
.cache/mozilla/firefox/smifthya.default/cache2/entries/15444D7EEEAF61418021BC35F25FD997974458B5
So I try to exclude those cache files from being synched by the following lines so far not successful.
What I tried so far:
rsync -va --delete --exclude={*Cache*, *cache*} /var/www/ $MYEXDISK/www
rsync -va --delete --exclude '*cache*' /var/www/ $MYEXDISK/www
rsync -va --delete --exclude 'cache*' /var/www/ $MYEXDISK/www
rsync -va --delete --exclude={Cache*, cache*} /var/www/ $MYEXDISK/www
Can anybody tell me the corect syntax to exclude any file, in which's path there is a variation of Cache or cache?
I believe you want:
set -B- brace expansion mode (possibly optional)
rsync -va --delete --exclude={**/Cache*,**/cache*} /var/www/ $MYEXDISK/www
See YoLinux then seach for INCLUDE/EXCLUDE PATTERN RULES. The relevant info is:
use '**' to match anything, including slashes.
The {...,...,...} is referred to as brace expansion.
It has very specific rules.
echo --exclude={foo,bar} => --exclude=foo --exclude=barecho --exclude={foo, bar} => --exclude={foo, bar}echo --exclude={foo} => --exclude={foo}echo --exclude=\'{foo,bar}\' => --exclude='foo' --exclude='bar'echo --exclude=\'{"foo bar",baz}\' => --exclude='foo bar' --exclude='baz'echo --exclude={'foo bar',baz} => --exclude=foo bar --exclude=bazecho --exclude=\'{foo bar,baz}\' => --exclude='{foo bar,baz}'If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With