Time Machine does not backup log files in ~/Library/Logs
But it does backup logs files within application containers. For example, log files in the folder ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail
.
My Mail and OneDrive logs are currently adding about 2 GB per backup.
I could manually exclude each of ~/Library/Containers/*/Data/Library/Logs
but that is a lot of exclusions and would be a list which needs addition whenever I install a new app.
The ~/Library/Containers/*
folders were introduced to support sandboxing applications, but Time Machine seems to have not kept up with these changes.
Is there a better way of telling Time Machine to not backup the /Log
folders within Containers?
I am using OS X Yosemite 10.10.1.
Best Answer
I had a similar need and using a combination of this answer and this answer I came up with the following solution.
Create a property list (e.g.
~/Library/LaunchAgents/excludeLogFiles.plist
) which will be loaded withlaunchctl load ~/Library/LaunchAgents/excludeLogFiles.plist
:Instead of using
EnableGlobbing
, which hasn't been supported since OS X 10.10 (ref), the path gets expanded by the program calling/bin/zsh <args>
.A couple of things I found while experimenting:
**
glob works withzsh
but notbash
~
should work in the path forProgramArguments
but I don't know if the same trick can be used forWatchPath
. Hard-coding the user path might be necessary.