A place for Unix Thoughts and Ideas

Taming OSX Time Machine Backups

OSX’s Time machine backup feature is very simple to enable and to use.

Unfortunately, it is almost too simple and there are no mechanisms for capping the amount of storage used for backups and it will eventually grow and take over any sized drive.

Really the best way to work with it is to dedicate a partition to just Time Machine and nothing else.

Time Machine will prune backups as they age and  when you run out of space, but depending on that functionality is very limiting.

It turns out that Time Machine has a very handy command line interface called tmutil for listing and deleting backups. It also has some additional compare commands that look like they could be very useful for tracking down changed files.

m-m:~ $ tmutil
Usage: tmutil help <verb>

Usage: tmutil version

Usage: tmutil enable

Usage: tmutil disable

Usage: tmutil startbackup [-b|--block]

Usage: tmutil stopbackup

Usage: tmutil enablelocal

Usage: tmutil disablelocal

Usage: tmutil snapshot

Usage: tmutil delete snapshot_path ...

Usage: tmutil restore [-v] src dst

Usage: tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name]
       tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name] snapshot_path
       tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name] path1 path2

Usage: tmutil setdestination mount_point
       tmutil setdestination [-p] afp://user[:pass]@host/share

Usage: tmutil addexclusion [-p] item ...

Usage: tmutil removeexclusion [-p] item ...

Usage: tmutil isexcluded item ...

Usage: tmutil inheritbackup machine_directory
       tmutil inheritbackup sparse_bundle

Usage: tmutil associatedisk [-a] mount_point volume_backup_directory

Usage: tmutil latestbackup

Usage: tmutil listbackups

Usage: tmutil machinedirectory

Usage: tmutil calculatedrift machine_directory

Usage: tmutil uniquesize path ...

Use `tmutil help <verb>` for more information about a specific verb.

The following is a example of listing my backups and then deleting one.

m-m:~ $ tmutil listbackups
m-m:~ $ sudo tmutil delete /Volumes/Data/Backups.backupdb/m-m/2012-10-30-135505

We can also run this in looped fashion to delete multiple backups

tmutil listbackups | egrep '2012-10-[01].-' | while read backup; do echo "Deleting $backup"; sudo tmutil delete $backup;done
Deleting /Volumes/Data/Backups.backupdb/m-m/2012-10-01-085459
Deleting /Volumes/Data/Backups.backupdb/m-m/2012-10-02-081339
Deleting /Volumes/Data/Backups.backupdb/m-m/2012-10-19-090310

Using tmutil you can take control of the aging of backups on your machine.

But as I mentioned, it is probably best to dedicate a drive or partition to Time machine.

That being said, if you want to delete all backups and start over. First, go into time machine and select “Do not backup.”  You then can remove Backups.backup directory. Running a standard delete will take forever.

Here is the quick way to bypass all permissions and acl’s and remove the backup directory:

m-m:~ $ sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/bypass rm -rf /Volumes/Data/Backups.backupdb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: