Skip to content

Instantly share code, notes, and snippets.

@PavelJurasek
Last active July 25, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PavelJurasek/926d9e9614fd4896cc935781df8dd299 to your computer and use it in GitHub Desktop.
Save PavelJurasek/926d9e9614fd4896cc935781df8dd299 to your computer and use it in GitHub Desktop.
Bash script for excluding development files from Time Machine backups
#!/bin/bash
# place this into your development directory (usually ~/Sites)
dir=$(cd `dirname $0` && pwd)
directories=(vendor node_modules temp log)
for dirname in "${directories[@]}"
do
# -maxdepth 2 can be changed to other depth or removed completely
for d in `find $dir -maxdepth 2 -type d -name $dirname`
do
`tmutil isexcluded $d | grep -q "Included"`
if [ $? -eq 0 ]; then
# -p can be removed so that given directory is not fixed, but rather mark directory itself as excluded no matter where you move it
tmutil addexclusion -p $d
echo "Dir $d is excluded now"
fi;
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment