Skip to content

Instantly share code, notes, and snippets.

@techouse
Last active September 19, 2024 14:18
Show Gist options
  • Save techouse/f2f25b38eb6a3d6a6027b3f21a1206af to your computer and use it in GitHub Desktop.
Save techouse/f2f25b38eb6a3d6a6027b3f21a1206af 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