I don't think this exact question has been asked before (I looked).
My backup server runs a script using Robocopy, and I want to exclude files that don't really need to be backed up, specifically:
*\AppData\Local\Google
*\AppData\Local\Microsoft\Windows
*\AppData\Local\NVIDIA
*\AppData\Local\Temp
*\AppData\LocalLow\Google
(all those have a million tiny cache files that take lots of time to parse but aren't needed for restore; most of the incremental backup run time is processing these)
The path prior to "\AppData..." varies, depending on the machine name, user name (multiple users per machine) and folder structure on that particular machine (not everyone has all their data on c:).
To keep things simple, I've got an environment variable called _exclude that I use in each call to Robocoy:
SET _exclude= /XD *AppData\Local\Google *AppData\Local\Temp [...etc]
I don't want to exclude every directory that contains "AppData" or "Local" or "Google", as that would exclude valuable data. Just those particular sub-paths.
I've tried it with and without leading '\', with and without double quotes around the paths, with/without '*', and permutations of those.
Is there any way to make this work with Robocopy, without hard-coding the particular path for every user on every machine?