OS X

Control Time Machine from the command line

Backing up your data is the most important thing you can do with your computer—even more important than tweeting or posting on Facebook. If you don’t back up your Mac regularly, you may lose those photos that you want to share; you may find that your latest holiday videos are missing; and your music library may go poof!

Time Machine is a great tool for ensuring that your data is safe, and it’s pretty easy to set up and use. But for some users, the basic Time Machine interface isn’t enough. As with most of OS X’s functions, there is a command-line tool that lets you do many things with Time Machine. Here’s how you can use the tmutil command to control and tweak Time Machine from Apple's command-line tool, Terminal.

The basics

Most people won’t need to use this command for their backups because the Time Machine interface will suffice. Who will need it? People who want to manage remote Macs or who want to run scripts containing commands for Time Machine.

The basics of the tmutil command can be found by typing man tmutil in Terminal. (You'll find the Terminal app in your /Applications/Utilities folder.) The man page tells you what you can do with this command.

For example, to turn Time Machine on or off, you can run these commands:

sudo tmutil enable

sudo tmutil disable

The sudo command is required for many of the commands you issue with tmutil because you need administrative privileges; you’ll have to enter your password after running the above commands.

If you want to run a Time Machine backup right away, on a Mac that either has Time Machine disabled, or, say, just before updating to a new version of OS X, you can run this command:

tmutil startbackup

This is the same as choosing Back Up Now from the Time Machine menu in the menu bar at the top of your screen.

And if you ever want to stop a backup, just run this:

tmutil stopbackup

Save disk space on your laptop

Since your laptop isn’t always connected to its backup disk, Time Machine retains “local snapshots,” or files that it will copy to your backup disk the next time it is available. However, these local snapshots take up space, and you may want to turn this feature off if you don’t have much room on your hard disk. You can do so with the following command:

sudo tmutil disablelocal

Running this command will also delete any local snapshots. You can turn local snapshots back on by running:

sudo tmutil enablelocal

Subscribe to the MacWeek Newsletter

Comments