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.

1 Answer 1


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 with launchctl load ~/Library/LaunchAgents/excludeLogFiles.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <string>tmutil addexclusion /Users/user/Library/Containers/**/Data/Library/Logs</string>

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:

  1. The ** glob works with zsh but not bash
  2. Using ~ should work in the path for ProgramArguments but I don't know if the same trick can be used for WatchPath. Hard-coding the user path might be necessary.
  • No ~ is not called through zsh - it gets expanded by the program calling /bin/zsh <args>
    – mmmmmm
    Commented Feb 10, 2017 at 20:24
  • Thanks for the clarification. I've updated the answer to hopefully be correct now.
    – Peter
    Commented Feb 10, 2017 at 20:31
  • You know what? With Sierra, nearly all my Containers/**/Data/Library/Logs are empty. So the problem has gone! Part of the Sierra changes to logging. But your answer looks correct - I hadn't thought of that method - obvious when you are shown it! So I will mark it as correct answer to the question for when I asked.
    – Gilby
    Commented Feb 11, 2017 at 5:02
  • Thanks. I used this to exclude sbt generated target dirs with a pattern like: tmutil addexclusion /Users/user/dev/*/target /Users/user/dev/*/*/target /Users/user/dev/*/*/*/target /Users/user/dev/*/*/*/*/target
    – Traveler
    Commented Feb 23, 2017 at 18:29
  • Note that the use of "*/target" was way way slower than explicit use of */*/
    – Traveler
    Commented Feb 23, 2017 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .