Auto-Excluding Folders from Time Machine via Terminal

Configurare noua (How To)

Situatie

Time Machine’s graphical interface lets you exclude folders one at a time by dragging them into the “Exclude these items” list, but this quickly becomes tedious if you have many cache folders, build directories, or virtual machine files that don’t need backing up. The tmutil command-line tool gives you far more precise and scriptable control, which is especially valuable for developers dealing with things like node_modules, Docker volumes, or Xcode’s DerivedData folder — all of which can balloon your backup size without adding any real value.

Solutie

  1. Open Terminal.
  2. Before making changes, check whether a specific folder is already excluded: tmutil isexcluded /path/to/folder — this returns a simple yes/no style answer.
  3. To exclude a single folder from all future Time Machine backups: sudo tmutil addexclusion /path/to/folder (you’ll need to enter your admin password since this requires elevated privileges).
  4. For excluding an entire directory tree recursively — useful for something like a Docker data folder — add the -pflag: sudo tmutil addexclusion -p ~/Library/Containers/com.docker.docker/Data/vms
  5. To see a full list of everything currently excluded, including exclusions set through the GUI: tmutil listexcludedfiles
  6. If you change your mind and want a folder backed up again: sudo tmutil removeexclusion /path/to/folder
  7. For power users, you can batch-exclude several developer-related folders at once by writing a small shell script that loops through common offenders, like node_modules, .cache, DerivedData, and any local VM disk images, then run it once after setting up a new Mac.

One thing worth noting: exclusions set via tmutil persist across Time Machine’s exclusion list and will show up (though sometimes greyed out) in System Settings → General → Time Machine → Options, confirming the change took effect. This approach is particularly valuable for anyone doing local development work, since build artifacts and dependency folders can easily add tens of gigabytes to a backup that offers zero real recovery value if lost.

Tip solutie

Permanent

Voteaza

(0 din 0 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?