Last active
July 25, 2017 12:54
-
-
Save PavelJurasek/926d9e9614fd4896cc935781df8dd299 to your computer and use it in GitHub Desktop.
Bash script for excluding development files from Time Machine backups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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