tmutil - macOS


Overview

tmutil is an essential Time Machine administration tool used to manage local snapshots and interact with Time Machine backups. It provides a powerful and flexible CLI interface for various backup-related tasks.

Syntax

tmutil [options/flags] <subcommand> [arguments]

Subcommands

  • inspectbackup: Examine the contents of a backup, listing backed-up files and folders.
  • listbackups: Display a list of all available backups in chronological order.
  • enable: Enable Time Machine for the specified disk or volume.
  • disable: Disable Time Machine for the specified disk or volume.
  • startbackup: Initiate a manual backup process.
  • stopbackup: Suspend the current backup process.
  • deletebackup: Remove a specific backup or a range of backups.
  • clearsnapshots: Delete local snapshots that are not part of a backup.
  • createlocal: Create a local snapshot for use with Time Machine.
  • deletelocal: Delete a specified local snapshot.
  • **compare`: Compares two backups, listing the differences between them.
  • **verifybackups`: Verifies the integrity of all backups, reporting any errors or inconsistencies.
  • **parsebackup`: Converts a sparseimage backup to a regular disk image.
  • **createset`: Creates a backup set for use with Time Machine.
  • **setdestination`: Sets the destination for future backups.
  • **timeremaining`: Estimates the remaining time required to complete a backup.
  • **thinlocalsnapshots`: Compacts local snapshots to save storage space.
  • **localsnapshotinterval`: Sets the interval at which local snapshots are created.
  • **version: Displays the version of tmutil`.

Options/Flags

  • -a, –all: Lists all backups, including those that are not mounted.
  • -d, –delete: Deletes the specified backup or local snapshot.
  • -v, –verbose: Enables verbose output, providing more detailed information about the command’s execution.
  • -h, –help: Displays help information about the command’s usage and options.

Examples

Inspecting a Backup

tmutil inspectbackup /Volumes/Backup1

Listing Local Snapshots

tmutil listlocalsnapshots /

Deleting a Backup

tmutil deletebackup -d /Volumes/Backup2

Creating a Local Snapshot

tmutil createlocal /

Estimating Backup Time Remaining

tmutil timeremaining

Common Issues

Unable to Access Backups

Ensure the backup disk or volume is properly connected and mounted. The listbackups command can help identify the available backups.

Slow Backup Performance

Check for any intensive background processes or network activity that may be interfering with the backup. Consider adjusting the backup frequency or using a wired network connection for better performance.

Incomplete Backups

If a backup fails to complete, verify the available disk space and run the verifybackups command to check for any inconsistencies. If corruption is detected, restore from an earlier backup.

Integration

Scripting with tmutil

tmutil can be utilized in scripts to automate backup management tasks. For example, the following script backs up a specified volume every day at midnight:

#!/bin/bash
VOLUME="/Volumes/MyData"
DATE=$(date +%Y-%m-%d)
tmutil startbackup -d $VOLUME $DATE

Time Machine Exclusions

Use the tmutil exclusionspath command to exclude specific files or folders from Time Machine backups:

tmutil exclusionspath /Users/Shared
  • diskutil: Disk management and partitioning.
  • rsync: Versatile file copy tool.
  • sudo: Execute commands as root.