#!/bin/bash # Find Time Machine System Files # This script identifies Time Machine files in system locations that may be taking up 100GB+ set -e echo "=== Time Machine System Files Finder ===" echo "" echo "Searching for Time Machine files in system locations..." echo "" TOTAL_SIZE=0 # Function to check and report size check_location() { local path=$1 local description=$2 if [ -e "$path" ]; then SIZE=$(sudo du -sh "$path" 2>/dev/null | awk '{print $1}') SIZE_BYTES=$(sudo du -sb "$path" 2>/dev/null | awk '{print $1}') if [ -n "$SIZE_BYTES" ] && [ "$SIZE_BYTES" -gt 0 ]; then echo " ✓ $description: $SIZE" echo " Path: $path" TOTAL_SIZE=$((TOTAL_SIZE + SIZE_BYTES)) fi fi } echo "🔍 Checking Time Machine locations:" echo "" # 1. Local snapshots echo "1. Local Snapshots:" SNAPSHOTS=$(tmutil listlocalsnapshots / 2>/dev/null | grep -v "Snapshots for disk" | grep -v "^$" | wc -l | tr -d ' ') if [ "$SNAPSHOTS" -gt 0 ]; then echo " Found $SNAPSHOTS snapshot(s):" tmutil listlocalsnapshots / 2>/dev/null | grep -v "Snapshots for disk" | grep -v "^$" | while read snapshot; do echo " - $snapshot" # Get snapshot size (requires root) SNAP_SIZE=$(sudo tmutil calculatedrift "$snapshot" 2>/dev/null | grep -i "size" | tail -1 || echo "") if [ -n "$SNAP_SIZE" ]; then echo " $SNAP_SIZE" fi done else echo " No local snapshots found" fi echo "" # 2. MobileBackups (APFS snapshots location) echo "2. MobileBackups (APFS Snapshots):" check_location "/System/Volumes/Data/.MobileBackups" "MobileBackups (newer macOS)" check_location "/.MobileBackups" "MobileBackups (older macOS)" check_location "/private/var/.MobileBackups" "MobileBackups (alternate location)" echo "" # 3. Time Machine sparse bundles in system locations echo "3. Time Machine Sparse Bundles:" find /private/var -name "*.sparsebundle" -o -name "*.sparseimage" 2>/dev/null | while read bundle; do if [ -e "$bundle" ]; then SIZE=$(sudo du -sh "$bundle" 2>/dev/null | awk '{print $1}') echo " Found: $bundle ($SIZE)" fi done find /System/Volumes/Data -maxdepth 3 -name "*.sparsebundle" -o -name "*.sparseimage" 2>/dev/null | while read bundle; do if [ -e "$bundle" ]; then SIZE=$(sudo du -sh "$bundle" 2>/dev/null | awk '{print $1}') echo " Found: $bundle ($SIZE)" fi done echo "" # 4. Time Machine preferences and data echo "4. Time Machine System Data:" check_location "/Library/Preferences/com.apple.TimeMachine.plist" "Time Machine preferences" check_location "/private/var/db/timezone" "Timezone data (may contain backups)" echo "" # 5. Check for old backup files in /private/var echo "5. System Backup Directories:" check_location "/private/var/backups" "System backups" check_location "/private/var/db" "Database files (may contain backup data)" echo "" # 6. Check for Time Machine logs (usually small but let's check) echo "6. Time Machine Logs:" LOG_SIZE=$(sudo du -sh /private/var/log/com.apple.TimeMachine* 2>/dev/null | awk '{sum+=$1} END {print sum}' || echo "0") if [ "$LOG_SIZE" != "0" ] && [ -n "$LOG_SIZE" ]; then echo " Log files: $LOG_SIZE" fi echo "" # 7. Check System/Volumes/Data for large Time Machine related files echo "7. System Volumes Data:" echo " Checking for large directories in /System/Volumes/Data..." sudo du -h -d 2 /System/Volumes/Data 2>/dev/null | grep -i "timemachine\|backup\|snapshot" | sort -hr | head -10 | while read line; do echo " $line" done echo "" # 8. Check for old Time Machine destinations echo "8. Time Machine Backup Destinations:" tmutil listbackups 2>/dev/null | head -5 BACKUP_COUNT=$(tmutil listbackups 2>/dev/null | wc -l | tr -d ' ') if [ "$BACKUP_COUNT" -gt 0 ]; then echo " Total backups listed: $BACKUP_COUNT" fi echo "" # 9. Check disk space breakdown echo "9. Disk Space Analysis:" echo " Running disk space analysis..." df -h / | tail -1 echo "" # 10. Check what macOS Storage Management shows echo "10. System Files Category:" echo " 💡 To see what macOS considers 'System Files':" echo " Apple Menu → About This Mac → Storage → Manage" echo " Look under 'System Files' category" echo "" # Summary echo "=== Summary ===" echo "" echo "To find the 100GB+ of Time Machine system files:" echo "" echo "1. Check macOS Storage Management:" echo " Apple Menu → About This Mac → Storage → Manage → System Files" echo "" echo "2. Check for local snapshots (APFS snapshots):" echo " tmutil listlocalsnapshots /" echo " sudo tmutil listlocalsnapshots /" echo "" echo "3. Check MobileBackups:" echo " sudo du -sh /.MobileBackups" echo " sudo du -sh /System/Volumes/Data/.MobileBackups" echo "" echo "4. Find all sparse bundles:" echo " sudo find / -name '*.sparsebundle' -o -name '*.sparseimage' 2>/dev/null" echo "" echo "5. Check system volumes:" echo " sudo du -h -d 1 /System/Volumes/Data | sort -hr | head -20" echo ""