Time Machine 10.8 – Part 3 – Advanced Features

Hello and welcome to the Amsys Training Podcasts.
My name is Russ, and today I will be taking you through the 3rd and final episode of this series about Time Machine in 10.8.
In the first episode, Hugo looked at Time Machine configuration and managing Time Machine backups. Pete took us through how to recover data in the second episode.
In this 3rd podcast, we will be looking at some advanced features such as:

– How to Encrypt your backups.
– How to manually modify the exclusions list.
– How to prevent New Disks being offered automatically For Backup.
– And an advanced way to change the schedule times for the backups.

Since this is the final episode in this podcast series, I’ve decided to give you a couple of bonus treats, and also cover some other features I think you will find useful.
So we will end the series with:

– How to toggle Local Snapshots on and off.
– How to setup a size limit for Time Machine backup volumes.
– And lastly, we will look at how to Delete Time Machine backups via the command line.

Encrypted Backup

A nice addition to Time Machine in 10.7 and 10.8 is the ability to encrypt your backup drive to increase the security of your backups.
When you connect up an new external hard drive to your Mac, it will automatically ask you if you want to use it to back up with Time Machine.
All you need to do is to Check the ‘Encrypt Backup Disk’ check-box and then Select ‘Use as Backup Disk’.
You’ll then be asked to enter a Secure Backup password and enter in a Password hint to help you remember this password should you forget it.
Please note, there is no way to recover the data if you forget this Backup password!
Click on the ‘Encrypt Disk’ button when you are ready to start the encryption process.
Episode One showed you how to manually setup Time Machine using the Preference Pane.
You can therefore also encrypt your backups here by checking ‘Encrypt backups’ when selecting the backup drive you want to use for backups.
Then click ‘Use Disk’ and again enter a Secure Backup password and enter in a Password hint to help you remember this password should you forget it.
Click on the ‘Encrypt Disk’ button to start the encryption process.
If you simply want to add encryption to an existing Time Machine backup, all you need to do in Time Machine Preferences, is reselect your backup drive after clicking the ‘Select Disk’ button and tick ‘Encrypt backups’, supplying a password and password hint when requested.

Exclusions (Terminal)

Hugo showed you in episode one how to exclude certain files and folders from your Time Machine backups using the Time Machine preference pane.
You can also configure exclusions using the command line which could be useful to system administrators who require a remote way to configure Time Machine.
If you have not used the command line before, be very careful when entering commands into the Terminal. Unlike the Finder, the command line is not forgiving with regards to typos and mistakes.
Open the terminal application, located in /Applications/Utilities and enter:

sudo tmutil addexclusion

then the path to the file or folder you wish to exclude.
For example, to exclude my Downloads folder from Time Machine backups, I would enter:

sudo tmutil addexclusion ~/Downloads

Remember, anytime you use the ‘sudo’ command, you will be asked to authenticate as an admin to make this change.
To verify that the exclusion has occurred, you can use the command:

sudo tmutil isexcluded

then the path to the file or folder in question.
To remove the exclusion, the command is:

sudo tmutil removeexclusion

then the path to the file or folder.

How tmutil exclusions work

The tmutil addexclusion command excludes items in a slightly different way to using a plist file. This command is what we like to call ‘Sticky’.
This means that the item you exclude remains in the Time Machine exclusion list even if you move it, this behaviour does NOT occur when you exclude items from the Time Machine preference pane. The reason for this, is because tmutil adds the exclusion to the metadata of the item excluded, instead of modifying a plist file. This means that the exclusion property permanently stays with the physical file.
To view an item’s exclusion, navigate to the item’s parent directory then enter:

ls -l@

Creating a ‘Traditional’ Exclusion

You can ‘unstick’ the exclusion by using the above addexlusion command with the -p flag added.
This exclusion will still not show up in Time Machine Preferences, but will be added to the /Library/Preferences/com.apple.TimeMachine.plist file along with traditional exclusions.

Viewing all tmutil Exclusions

If you wish to see all the files that have been excluded using this metadata technique, you can use the following command:

sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"

Default Exclusions

The default exclusions applied by Time Machine which were discussed in Episode one, are stored inside a .plist file called ‘StdExclusions.plist’, this is located within the backupd.bundle inside /System/Library/CoreServices/backupd.bundle
These default exclusions do not appear in the Time Machine Preferences window.
To see a list of these exclusions, enter the following two commands:

'cd /System/Library/CoreServices/backupd.bundle/Contents/Resources/'

followed by

'less StdExclusions.plist'

You can see that there are a fair amount of files and folders that are excluded here by default.

Prevent New Disks Being Offered

As great as Time Machine is, you may regularly connect additional hard drives to a mac that does not need Time Machine configured. It can be rather frustrating to keep dismissing the dialog window that appears every time you connect an additional drive, asking you if you would like to use this drive for backups.
A .plist file can be easily modified to remove this popup window. Simply enter the following command in Terminal:

defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool YES

Your user’s ~/Library/Preferences/com.apple.TimeMachine.plist will be correctly updated to never give you this popup whenever you connect an additional hard drive.

Change Schedule

As discussed in Episode 1 of this series, Time Machine’s default schedule is every hour and this cannot be changed within the GUI.
Using the command line, you can manually adjust the Time Machine backup schedule.
To do this, you need to specify the schedule interval in seconds. The default hourly schedule is therefore 3600 seconds. (60 seconds multiplied by 60 minutes). If you wanted to wait 2 hours between backups, the number would therefore be 7200 seconds.
To set this 2 hour schedule, the command would be:

sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 7200

UPDATE ALERT: (Thanks Luis!)
Please note that it seems somewhere in an update to 10.8, the settings for the section on “To set this 2 hour schedule” have changed, whereby the StartInterval key was renamed BackupInterval within a launchEvents key of the com.apple.backupd-auto.plist file.
The quickest way to achieve this now will be to download Textwrangler, XCode or any other Text editor of your choice and open the /System/Library/LaunchDaemons/com.apple.backupd-auto.plist with this application.
You can then modify the ‘Backup Interval’ integer key to ’7200′ or whatever interval of seconds you require.

TimeMachineScheduler in Action

A great free app is also available to download to allow you to modify the schedule using an alternative System Preference Pane. TimeMachineScheduler disables the automatic backup function of Time Machine and installs its own background process for Time Machine.
Just as with the defaults write commands, you can adjust the backup interval, but you can also skip backups between scheduled times which is handy.
Once you have installed the App, you can open it’s System Preference Pane.
Click ‘Install’ to disable the Apple Time Machine Preferences and install the additional scheduler.
You can now tweak your Backups without having to use the command line. I’ve set the backups to every 3 hours and to skip backing up between 10am and 11am.

Local Snapshots on and off via Terminal

Episode 1 explained that Local Snapshots are stored within a hidden folder called .MobileBackups.
If you decide you do not want Local snapshots and want to recover the hard disk space, you can easily disable local snapshots in the terminal using the following command:

sudo tmutil disablelocal

Just use

sudo tmutil enablelocal

to renable local snapshots.
If you have local snapshots enabled and you wish to manually create a new local Time Machine snapshot, you can enter:

sudo tmutil snapshot

The Local Snapshot Preference is viewable in /Library/Preferences/com.apple.TimeMachine.plist
It is worth noting that if you turn off Time Machine and then turn it back on, Local snapshots will be turned back on for portable computers, if currently disabled. You must execute the disablelocal command again to disable local snapshots again.
As well as disabling Local Snapshots to delete them, you can turn Time Machine off, which will also delete all existing Snapshots.
Note that this may take a while to delete.

Maximum Backup Size Limit

Time Machine by default will use all the available disk space on your backup drive. The good news is that you can setup a maximum limit that Time Machine can use. All you need to do is specify in megabytes the maximum space limit. You can do this by multiplying your Gigabyte preference by 1024 bytes. For example if I wanted the maximum backup space to be 100GB, I would multiply 100 by 1024 which equals 102400.
I can then enter this terminal command:

sudo defaults write /Library/Preferences/com.apple.TimeMachine MaxSize 102400

This preference can be viewed within the /Library/Preferences/com.apple.TimeMachine.plist file
To remove the limit, use the following command:

sudo defaults delete /Library/Preferences/com.apple.TimeMachine MaxSize

Delete Time Machine Backups

The default way to delete backups is to use the Action Menu within the Time Machine interface.
However, sometimes this may fail for example if you haven’t the correct permissions. You may even receive an error message like
‘The operation can’t be completed because backup items can’t be modified’.
Luckily, the command line can come to your rescue once more. Enter in Terminal :

sudo /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass rm -rfv

then the path to the required backup.
Terminal will now display a list of the files as they are deleted. Obviously, the larger the backup, the longer this will take, so perhaps perform this during lunchtime or overnight!
Well, that is the end of our Time Machine Podcast series. We hope you have enjoyed the series, and keep an eye out for our next Podcast.
On behalf of all here at Amsys, thank you for watching.