Programmatically mark file(s) to be ignored by Time Machine I'm writing some code that produces a kind of package file, however it includes a kind of working database that isn't strictly necessary (as it can be re-computed) but is best kept bundled with the package file.

Anyway, the problem is that the database can get quite large, and often changes are fairly small, this means that these databases are always being backed up by Time Machine, which is very wasteful as they don't really add anything important to back-ups.

I can't really ask the end-users to mark these databases manually for every package in their Time Machine preferences, especially if they move the package file around and forget. But I also don't want these databases to be waisting a bunch of space in their Time Machine backups, as it could cause premature pruning of old backups with no useful benefits.

I've already considered moving the databases into the user's ~/Library/Caches folder but this is a lot more complicated to manage. The database is also useful within the package as it eliminates a somewhat lengthy pre-compute step.

So; is there any other means by which I can tell Time Machine to ignore a file or folder? Ideally something I can do via script, but if it requires a small program it's not a huge issue.
There is a C function 'CSBackupSetItemExcluded' you can use to tell Time Machine to exclude a file.

You can find it documented here...

https://developer.apple.com/library/mac/documentation/MacOSX/Reference/Backup/#//apple_ref/c/func/CSBackupSetItemExcluded