How to use the command 'tmutil' (with examples)
- Osx
- December 25, 2023
The tmutil
command is a utility for managing Time Machine backups on macOS. It allows users to set backup destinations, enable or disable automatic backups, start or stop backups, and more. This article will illustrate several use cases for the tmutil
command.
Use case 1: Set an HFS+ drive as the backup destination
Code:
sudo tmutil setdestination path/to/disk_mount_point
Motivation: Setting an HFS+ drive as the backup destination allows Time Machine to use the specified drive for storing the backups.
Explanation:
sudo
: Thesudo
command is used to runtmutil
with root privileges.tmutil setdestination
: This subcommand is used to set the backup destination.path/to/disk_mount_point
: It should be replaced with the actual path to the HFS+ drive’s mount point.
Example output:
Destination set to 'path/to/disk_mount_point'.
Use case 2: Set an APF share or SMB share as the backup destination
Code:
sudo tmutil setdestination "protocol://user[:password]@host/share"
Motivation: By setting an APF share or SMB share as the backup destination, Time Machine can backup data directly to a network share.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil setdestination
: This subcommand is used to set the backup destination."protocol://user[:password]@host/share"
: It should be replaced with the actual connection details of the APF share or SMB share. Theprotocol
can be eitherafp
orsmb
.
Example output:
Destination set to 'afp://user:password@host/share'.
Use case 3: Append the given destination to the list of destinations
Code:
sudo tmutil setdestination -a destination
Motivation: Appending a destination to the list of destinations allows Time Machine to use multiple destinations for storing backups.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil setdestination
: This subcommand is used to set the backup destination.-a
: This option is used to append the given destination to the list of destinations.destination
: It should be replaced with the actual destination to be appended.
Example output:
Destination 'destination' added to the list of destinations.
Use case 4: Enable automatic backups
Code:
sudo tmutil enable
Motivation: Enabling automatic backups allows Time Machine to automatically backup the system at regular intervals.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil enable
: This subcommand is used to enable automatic backups.
Example output:
Automatic backups enabled.
Use case 5: Disable automatic backups
Code:
sudo tmutil disable
Motivation: Disabling automatic backups stops Time Machine from performing scheduled backups.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil disable
: This subcommand is used to disable automatic backups.
Example output:
Automatic backups disabled.
Use case 6: Start a backup, if one is not running already, and release control of the shell
Code:
sudo tmutil startbackup
Motivation: Starting a backup allows Time Machine to backup the system’s data to the configured destination.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil startbackup
: This subcommand is used to start a backup.- No additional arguments are provided to release control of the shell.
Example output:
Backup started successfully. Shell control released.
Use case 7: Start a backup and block until the backup is finished
Code:
sudo tmutil startbackup -b
Motivation: Blocking the shell until the backup is finished allows the user to wait for the backup operation to complete without releasing control of the shell.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil startbackup
: This subcommand is used to start a backup.-b
: This option is provided to block until the backup is finished.
Example output:
Backup started successfully. Shell blocked until backup completed.
Use case 8: Stop a backup
Code:
sudo tmutil stopbackup
Motivation: Stopping a backup allows the user to manually halt a backup operation if needed.
Explanation:
sudo
: This command is used to runtmutil
with root privileges.tmutil stopbackup
: This subcommand is used to stop a backup.
Example output:
Backup stopped successfully.
Conclusion:
The tmutil
command is a powerful utility for managing Time Machine backups on macOS. With its various subcommands and options, users can set backup destinations, enable or disable automatic backups, start or stop backups, and more. By following the examples provided in this article, users can effectively utilize the tmutil
command to manage their Time Machine backups.