Avatar

Hi, I'm Stefan

I write code, love tools that help doing that, learn new things, and this is the place where I write about that.


March 30, 2024 Tips and Tricks

Exclude node_modules folder from Time Machine backup

On macOS, TimeMachine is a great tool for backing up your Mac. However, if you work on a lot of JavaScript projects, you probably have a couple of node_modules folders that don’t need to be included in your backup. Here is how you can list, add and remove folders from your Time Machine backup.

# List currently excluded node_modules folders
$> sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'" | grep "node_modules"

# Exclude a folder from backup
$> tmutil addexclusion ABSOLUTE_PATH_TO_FOLDER

# Remove folder from the list of excluded folders
$> tmutil removeexclusion ABSOLUTE_PATH_TO_FOLDER

Of course, this also works with any other folder, not only node_modules.

If you don’t want to use the terminal, you can also use macOS’ system settings: System Settings -> General -> Time Machine -> Options (for macOS Sonoma).

Share and discuss →