Sub topic 12
Controlling Time Machine from Terminal with tmutil
This chapter assumes you can open Terminal and run simple commands, and that Time Machine is already set up with a destination (see the setup chapters). tmutil is the command-line tool that ships with macOS for controlling Time Machine. It does what the Time Machine settings do, and it also exposes details the settings hide, such as exact backup paths and snapshot names. It is useful for scripting, for working over SSH, and for checking state quickly.
What tmutil is and when to use it
The settings pane is fine for turning Time Machine on and choosing a disk. tmutil is better when you want to:
- Start or stop a backup from a script or a remote session.
- Read the current state in plain text.
- Manage exclusions for many folders at once.
- Inspect or delete local snapshots.
- Confirm how recent your last backup is.
Most commands are read-only and safe. Some change configuration or delete data, and those usually need administrator rights through sudo. This chapter flags them.
How the pieces fit together
tmutil talks to the same background service that the settings pane uses. A command either reads state (destinations, status, backups) or asks the service to do something (start, stop, exclude).
Listing destinations
Start by checking which destinations Time Machine knows about.
tmutil destinationinfoThe output lists each destination with a name, a kind (for example Local for a directly attached disk or Network for a share), and an ID. The ID is a UUID. You need it when a command must target one destination, which matters if you rotate between several disks.
If the output says there are no destinations, Time Machine is not configured and nothing else in this chapter that touches backups will work yet.
Starting a backup and checking status
To start a backup now, run:
tmutil startbackup --blockWithout --block, the command returns immediately and the backup runs in the background. With --block, the command stays running until the backup finishes. That is what you want in a script that must wait, for example before shutting down a machine. Press Control-C to stop waiting. Interrupting the wait does not necessarily stop the backup itself.
While a backup runs, check on it from another Terminal window:
tmutil statusThe output is a property list style block. These fields are the ones to look for:
| Field | Meaning |
|---|---|
| `Running` | `1` if a backup is in progress, `0` if not |
| `BackupPhase` | The current stage, such as `Starting`, `ThinningPreBackup`, `Copying`, or `Finishing` |
| `Percent` | Overall progress as a fraction. It can show `-1` while Time Machine is still estimating the amount of work |
| `DestinationID` | The destination being written to |
Percent is often unreliable early on. Time Machine first measures what changed, and only then can it give a meaningful figure. Do not treat -1 as an error.
To stop a running backup, use tmutil stopbackup. It is safe to stop and start again. The next run continues from the changes it still has to copy.
Checking how recent your last backup is
A backup that quietly stopped weeks ago is the most common real failure. This command prints the path of the newest backup:
tmutil latestbackupThe path ends in a timestamp, such as 2026-11-27-094512, so you can read the date and time directly. If the command prints an error, common causes are:
- The backup disk is not connected or the network share is not mounted.
- Terminal lacks Full Disk Access.
- The destination is encrypted and not unlocked.
To see every backup rather than only the latest, use tmutil listbackups. Each line is one backup path, oldest first. Because Time Machine thins old backups (see the schedule and retention chapter), the list gets sparser as you go back in time.
Managing exclusions
Exclusions keep large, replaceable data out of backups. Here is how to add one and confirm it.
tmutil addexclusion ~/Downloads/large-files
tmutil isexcluded ~/Downloads/large-filesisexcluded prints [Excluded] or [Included] followed by the path, so you can verify the change worked.
There are two kinds of exclusion, and the difference causes confusion:
| Kind | Command | How it is stored | What happens when you move the folder |
|---|---|---|---|
| Sticky (default) | `tmutil addexclusion path` | As a flag on the item itself | The exclusion moves with the item |
| Fixed path | `tmutil addexclusion -p path` | As a path in the Time Machine configuration | The exclusion stays at the old path, so the moved item is included again |
Fixed-path exclusions need sudo and apply to every user on the Mac. Use them for system locations. Use sticky exclusions for your own folders.
To undo an exclusion, use the matching remove command:
tmutil removeexclusion ~/Downloads/large-filesFor a fixed-path exclusion, add -p and sudo again.
Local snapshots
Local snapshots are point-in-time copies kept on your startup disk. They let you restore recent versions even when the backup disk is away. List them like this:
tmutil listlocalsnapshots /The argument is the volume's mount point, here / for the startup volume. Each line is a snapshot name that includes a date. macOS removes snapshots automatically when it needs the space, so you rarely need to manage them by hand.
To delete one snapshot by its date, use sudo tmutil deletelocalsnapshots 2026-11-27-094512. This is a destructive action and cannot be undone. Check the date against the list first.
A small health-check script
You can combine these commands into one script that reports whether a backup exists and whether it is recent. This one uses only tmutil, stat, and date, which are all present on macOS. It treats a backup older than 24 hours as stale.
#!/bin/bash
# Report the age of the latest Time Machine backup.
latest=$(tmutil latestbackup 2>/dev/null)
if [ -z "$latest" ]; then
echo "No backup found. Is the destination connected and unlocked?"
exit 1
fi
# Folder modification time as seconds since 1970
modified=$(stat -f %m "$latest")
now=$(date +%s)
age_hours=$(( (now - modified) / 3600 ))
echo "Latest backup: $latest"
echo "Age: ${age_hours} hours"
if [ "$age_hours" -gt 24 ]; then
echo "Warning: the latest backup is more than 24 hours old."
exit 2
fiSave it as tm-check.sh, run chmod +x tm-check.sh, then ./tm-check.sh. The exit codes (0 fine, 1 missing, 2 stale) let another tool, such as a scheduled job, react to the result.
The folder's modification time is a close, but not exact, stand-in for the backup time. For a human check, the timestamp in the path is the more precise source.
Common mistakes
- Running
startbackupwith no destination. The command appears to succeed, but nothing is written. Rundestinationinfofirst. - Forgetting
sudofor system changes. Fixed-path exclusions and snapshot deletion fail with a permission error without it. - Reading
Percent: -1as a failure. It means the estimate is not ready yet. - Assuming exclusion frees space. It only affects future backups.
- Skipping Full Disk Access. Several read commands then return empty output or errors even though backups are fine.
Exercise
A script runs tmutil startbackup and then immediately shuts the Mac down. Backups sometimes do not finish. What is wrong, and how do you fix it?
Show answer
Without --block, startbackup returns at once while the backup continues in the background, so the shutdown can interrupt it. Use tmutil startbackup --block so the script waits until the backup finishes before the shutdown command runs.
Exercise
You moved a folder you had excluded with tmutil addexclusion -p, and it is now being backed up. Why, and what would have avoided this?
Show answer
A fixed-path exclusion is tied to the original path, not to the folder itself, so the folder at its new location is no longer excluded. A sticky exclusion (tmutil addexclusion without -p) is stored on the item and moves with it.
Exercise
tmutil latestbackup prints an error although your backup disk is plugged in. Name two causes you should check.
Show answer
Terminal may lack Full Disk Access, and an encrypted destination may not be unlocked. Also confirm the disk is mounted and shown by tmutil destinationinfo.