What Is Time Machine?
Time Machine is the automatic backup system built into macOS. It automatically creates hourly, daily, and weekly snapshots, allowing you to restore anything from individual files to the entire system. External disks, NAS, and Time Capsule can be used as backup targets.
This article covers Time Machine basic setup, exclusion folder management, file restoration, and NAS network backup.
Basic Setup
When an external disk is connected, macOS automatically asks whether to use it as a Time Machine backup disk. Manual setup is also possible.
# Check Time Machine status
tmutil status
# Sample output:
# {
# BackupPhase = Copying;
# DateOfStateChange = "2026-03-05 01:00:00 +0000";
# Percent = "0.85";
# Running = 1;
# }
# Check backup disk list
tmutil destinationinfo
# Sample output:
# ====================================================
# Name : Backup HD
# Kind : Local
# Mount Point : /Volumes/Backup HD
# ID : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
# Add external disk as Time Machine backup target
sudo tmutil setdestination /Volumes/BackupDisk
# Add additional backup target (keep existing ones)
sudo tmutil setdestination -a /Volumes/SecondBackup
Backup Activation and Schedule
# Enable Time Machine
sudo tmutil enable
# Disable Time Machine
sudo tmutil disable
# Start manual backup immediately
tmutil startbackup
# Stop backup in progress
tmutil stopbackup
# Check next scheduled backup time
tmutil status | grep -i "date"
# Check most recent backup time
tmutil latestbackup
# Sample output: /Volumes/Backup HD/Backups.backupdb/MacBook/2026-03-05-010000
# List all backup snapshots
tmutil listbackups
# Output: list of backup paths by date
By default, Time Machine runs automatic backups every hour. Since macOS Ventura, you can change the backup frequency in settings (manual, hourly, daily, weekly).
Exclusion Folder Settings
Excluding large development-related directories that don’t need backup can save backup time and disk space.
# Add exclusion folders
sudo tmutil addexclusion ~/Library/Caches
sudo tmutil addexclusion ~/node_modules
sudo tmutil addexclusion ~/.docker
sudo tmutil addexclusion ~/Library/Developer/Xcode/DerivedData
# Exclude unnecessary folders within development projects
sudo tmutil addexclusion ~/Projects/myapp/node_modules
sudo tmutil addexclusion ~/Projects/myapp/.next
sudo tmutil addexclusion ~/Projects/myapp/dist
# Fixed exclusion (persists even if path changes)
sudo tmutil addexclusion -p ~/VirtualMachines
# Check current exclusion list
sudo tmutil isexcluded ~/Library/Caches
# Output: [Excluded] /Users/username/Library/Caches
# Remove exclusion
sudo tmutil removeexclusion ~/Library/Caches
Here’s a list of folders developers commonly benefit from excluding.
# Batch exclusion setup script for developers
#!/bin/bash
# exclude-dev-dirs.sh
# Package manager caches
EXCLUDE_DIRS=(
"$HOME/Library/Caches"
"$HOME/Library/Developer/Xcode/DerivedData"
"$HOME/Library/Developer/CoreSimulator"
"$HOME/.docker"
"$HOME/.gradle"
"$HOME/.m2"
"$HOME/.cargo/registry"
"$HOME/.npm/_cacache"
"$HOME/.pyenv/versions"
)
for dir in "${EXCLUDE_DIRS[@]}"; do
if [ -d "$dir" ]; then
sudo tmutil addexclusion "$dir"
echo "Excluded: $dir"
fi
done
# Find and exclude all node_modules
find "$HOME/Projects" -name "node_modules" -type d -maxdepth 4 | while read dir; do
sudo tmutil addexclusion "$dir"
echo "Excluded: $dir"
done
echo "Exclusion setup complete!"
File Restoration
You can restore deleted or overwritten files from Time Machine. There are two methods: GUI and CLI.
GUI Restoration
Open the folder containing the file you want to restore in Finder, then click the Time Machine icon in the menu bar and select “Enter Time Machine.” Navigate to the desired point in time on the timeline, then click the “Restore” button.
CLI Restoration
# Find specific files in backups
tmutil listbackups | tail -5
# Check the 5 most recent backup paths
# Copy file directly from backup path
BACKUP="/Volumes/Backup HD/Backups.backupdb/MacBook/2026-03-04-150000"
cp "$BACKUP/Data/Users/username/Documents/important-file.txt" ~/Desktop/
# Restore entire folder from a specific date's backup
tmutil restore \
"$BACKUP/Data/Users/username/Projects/myapp/" \
~/Desktop/myapp-restored/
# Check APFS snapshot list (local snapshots)
tmutil listlocalsnapshots /
# Sample output:
# com.apple.TimeMachine.2026-03-05-010000.local
# com.apple.TimeMachine.2026-03-04-230000.local
Local Snapshot Management
Time Machine automatically creates local APFS snapshots even when no external disk is connected. These snapshots allow you to restore recent changes without an external disk.
# List local snapshots
tmutil listlocalsnapshots /
# Output:
# com.apple.TimeMachine.2026-03-05-010000.local
# com.apple.TimeMachine.2026-03-04-230000.local
# com.apple.TimeMachine.2026-03-04-210000.local
# Delete a specific local snapshot (reclaim disk space)
sudo tmutil deletelocalsnapshots 2026-03-04-210000
# Delete all local snapshots
for snapshot in $(tmutil listlocalsnapshots / | grep -o '20[0-9-]*'); do
sudo tmutil deletelocalsnapshots "$snapshot"
done
# Check disk space used by local snapshots
tmutil listlocalsnapshots / | wc -l
# Check snapshot count
df -h /
# "purgeable" area includes local snapshots
NAS Network Backup
Time Machine also supports backup to network drives (NAS). Most NAS devices from Synology, QNAP, and others provide Time Machine services.
# Set SMB share as Time Machine backup target
# 1. First connect to NAS in Finder
# Cmd+K → smb://nas-ip/TimeMachine
# 2. Add backup target via CLI
sudo tmutil setdestination -a "smb://user:password@nas-ip/TimeMachine"
# 3. Verify network backup target
tmutil destinationinfo
# Sample output:
# ====================================================
# Name : TimeMachine
# Kind : Network
# URL : smb://nas-ip/TimeMachine
# ID : YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY
# Set network backup disk size limit
# Set quota in NAS admin page, or:
sudo defaults write /Library/Preferences/com.apple.TimeMachine \
MaxSize -integer 500 # 500GB limit
General steps to enable Time Machine service on a NAS:
- Access the NAS admin page
- Create a shared folder “TimeMachine”
- Enable SMB in file services
- Enable Time Machine service and assign the shared folder
- Select the NAS in Time Machine settings on your Mac
Migrating to a New Mac
You can use a Time Machine backup to transfer your entire environment to a new Mac.
# Verify latest backup before migration
tmutil latestbackup
# Migration method:
# 1. Select "Migration Assistant" during new Mac initial setup
# 2. Choose "From a Time Machine Backup"
# 3. Connect backup disk or select network
# 4. Choose items to transfer (apps, settings, documents, etc.)
# Post-migration checklist
# - Re-authenticate app licenses
# - Verify SSH key operation
ssh -T git@github.com
# - Check Homebrew packages
brew list
# - Verify development tool versions
node --version
python --version
Summary
Key points for Time Machine backup management:
- Automatic backup: Once Time Machine is enabled, it backs up automatically every hour with no management needed
- Exclusion folders: Exclude large regenerable folders like
node_modules,DerivedData, and.docker - Local snapshots: APFS snapshots allow restoring recent changes even without an external disk
- NAS backup: Back up automatically over the network without needing to connect an external disk each time
- Disk size: A backup disk 2-3x the Mac’s storage capacity is recommended
- Migration: Transferring to a new Mac is simple with Time Machine
- Encryption: Enabling backup disk encryption protects data even if the external disk is lost