Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save b159732000/79a16c65339273de064e2eda39b993f8 to your computer and use it in GitHub Desktop.
Save b159732000/79a16c65339273de064e2eda39b993f8 to your computer and use it in GitHub Desktop.
Instruct Time Machine to exclude some development directories
#!/usr/bin/env bash
# This simple bash script is aimed at excluding some development specific directories.
#
# In this configuration it will instruct Time Machine to exclude directories named:
# - env
# - node_modules
# - vendor
# - venv
#
# Feel free to update this array to your own needs.
EXCLUDED_DIRECTORIES=( "env" "node_modules" "vendor" "venv" )
WORK_DIR=$(dirname "${BASH_SOURCE[0]}")
WORK_DIR=$(realpath "${WORK_DIR}")
for EXCLUDED_DIRECTORY in "${EXCLUDED_DIRECTORIES[@]}"; do
find ${WORK_DIR} -maxdepth 2 -type d -name ${EXCLUDED_DIRECTORY} -prune -exec tmutil addexclusion {} \;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment