Help with rsync excludes

Trying to setup a script to copy most of my home folder to a network share, and coming up against a wall. Trying to exclude the .cache folder, but it’s being copied anyway. Wondering if some seasoned veterans might have some insight on what I’m missing.

rsync -avL --no-specials --delete --exclude=/.cache --exclude=/.steam --exclude=/.ICAClient /home /media/TheVault/Backups/DailyHomeBackup

/.cache is not in your home folder ; that’s in root
/home/username/.cache is in your home folder; you need to specify the absolute path

I use --exclude-from option and add multiple items to a file

Try is like this, with the the / after the folder and while using "
rsync -avL --no-specials --delete --exclude “.cache/” --exclude “.steam/” --exclude “.ICAClient/” /home /media/TheVault/Backups/DailyHomeBackup

1 Like

Thanks Tom, that did the trick. I had tried using the absolute path of /home/rick/.cache/* in previous tries, and wasn’t having any luck. Syntax was just a little bit off.

Glad Tom solved it for you. I am surprised the absolute path fails, but I confirmed it using --exclude as you did. However, when I use --exclude-from=path-to-file-with-excludes
I can exclude .cache, .local, .anything as long as I use a / or * wild card. Since I exclude all hidden files, I run with .* in my exclude file. But .cache/ or .cache* in the exclude file does what you’re looking for and avoids a long list of excludes on your rsync command.

I need to read up on the --exclude option, but my preference is the exclude file.

–exclude=.cache or --exclude=.local or --exclude=.* worked for me same as reported above