Sub topic 12
Controlling Time Machine from Terminal with tmutil
This chapter assumes you have already turned on Time Machine, run a first backup, and set exclusions in System Settings. You should also be comfortable opening Terminal and running short commands. tmutil is the command-line tool that ships with macOS for managing Time Machine. It is useful for scripts, remote sessions over SSH, and quick checks.
What tmutil can do
Some commands only read information. Others change settings or start work. Commands that change settings usually need administrator rights, so you add sudo and enter your password.
| Task | Command | Changes anything? |
|---|---|---|
| List destinations | `tmutil destinationinfo` | No |
| Show backup state | `tmutil status` | No |
| Show newest backup | `tmutil latestbackup` | No |
| Start a backup | `tmutil startbackup` | Yes |
| Add or check an exclusion | `tmutil addexclusion`, `tmutil isexcluded` | Yes / No |
| List local snapshots | `tmutil listlocalsnapshots /` | No |
Check your destinations
Start by confirming which destinations Time Machine knows about.
tmutil destinationinfoThe output lists each destination with its name, kind (local or network), and ID. Use the ID when you need to point other commands at one destination.
Start a backup and watch it
By default, startbackup returns immediately and the backup runs in the background. Add --block to make the command wait until the backup finishes. This is useful in scripts that must not continue until the backup is done.
tmutil startbackup --blockIn a second Terminal window, check progress while it runs.
tmutil statusThe output shows whether a backup is running, which phase it is in, and how far along it is.
Find your most recent backup
tmutil latestbackupThis prints the path of the newest backup. The date in the path tells you how recent your last backup is.
Manage exclusions
You can exclude a folder from backups and then confirm the setting.
tmutil addexclusion ~/Downloads/large-files
tmutil isexcluded ~/Downloads/large-filesisexcluded prints [Excluded] or [Included] followed by the path. Without -p, addexclusion marks the item itself, so the exclusion follows the item if you move it. Adding -p fixes the exclusion to that path instead. Fixed-path exclusions need sudo.
List local snapshots
Local snapshots are short-lived copies kept on your startup volume. List them with:
tmutil listlocalsnapshots /The / is the volume to inspect. Each line shows a snapshot name that includes a date and time.
A typical check sequence
Common errors
- Operation not permitted: Terminal lacks Full Disk Access. Grant it and restart Terminal.
- Permission denied on a change: repeat the command with
sudo. - No destinations configured:
destinationinfoshows nothing. Add a destination in System Settings first. - Backup does not start: the destination may be unplugged or unreachable. Check
destinationinfo, then reconnect the disk or network share.
Exercise
You want a script to start a backup and only continue to the next step once the backup has finished. Which command do you use, and which option makes it wait?
Show answer
Use tmutil startbackup --block. The --block option keeps the command running until the backup finishes. Without it, the command returns right away and the backup runs in the background.
Exercise
You excluded ~/Downloads/large-files. How do you confirm that Time Machine treats it as excluded, and does the exclusion remove copies from earlier backups?
Show answer
Run tmutil isexcluded ~/Downloads/large-files, which prints [Excluded] for the path. The exclusion does not remove copies from earlier backups. It only keeps the folder out of future backups.