Terminal 101: Control Time Machine from the Command Line
Posted 06/18/2012 at 10:35am
| by Cory Bohon
Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!
Time Machine is Apple’s answer to backup. It’s simple, it’s elegant, and it just works. However, you can still use the backup utility built into your Mac through the command line and over SSH. Very handy for those times when you may not have physical (or screen sharing) access to your Mac remotely.
In this week’s tip, we’ll show you some of the basics of backing up your Mac using Time Machine through the Terminal and using the tmutil program.
It should be noted that in order to use the tmutil program, you must be running Mac OS X 10.7 (Lion) or later.
Enabling / Disabling Time Machine

To enable or disable time machine (same as flipping the ON/OFF switch in the System Preference pane), you’ll want to use the following command:
sudo tmutil disable
Replace "disable" above with "enable" to enable Time Machine again. If you have not authenticated recently as a sudoer, you will be prompted to provide your administrator password.
Change the Backup Disk

You can also change the disk that Time Machine uses to back up your Mac. You’ll use the setdestination command to help with that.
First, you’ll want to list your attached disks so that you can use that information later to set the backup destination drive. To do that, use the following command to list the attached volumes:
ls /Volumes
In the list of attached volumes, jot down the name of your drive so that you can use it to complete the setdestination command to change the drive for your Time Machine backups, like this:
sudo tmutil setdestination /Volumes/mydisk
Replace “mydisk” in the above command with the name of your drive, which was in the list of volumes connected to your Mac. (Note: You can also use tab-completion by typing in “sudo tmutil setdestination /Volumes/” and typing the first few characters of the volume name, and pressing tab to automatically complete the command.)
Back Up on Command

One of the best things about Time Machine is that it’s automatic, but you can also back up on command, whenever you wish. You can also do that in the Terminal by using the following command:
tmutil startbackup
You can also stop the current backup in progress by typing the following command:
tmutil stopbackup
Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, Cory Bohon on Twitter.