Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save osopolar/9d8e8188091f7cbbfcee924ccfbb32dd to your computer and use it in GitHub Desktop.
Save osopolar/9d8e8188091f7cbbfcee924ccfbb32dd to your computer and use it in GitHub Desktop.
Exclude node_modules (and more) from timemachine, use launchd to scan the Project directory on a regular basis, for example meanwhile you are having siesta. Put this file in ~/Library/LaunchAgents and call `launchctl load ~/Library/LaunchAgents/com.user.time-machine-exclude-node-modules-job.plist`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.time-machine-exclude-node-modules-job</string>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>cd "$HOME/Projects" &amp;&amp; find $(pwd) -type d \( -name vendor -o -name node_modules \) -prune -exec tmutil addexclusion {} \; -exec tmutil isexcluded {} \;</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>13</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
<!-- Debug logging -->
<!--
<key>StandardOutPath</key>
<string>/tmp/launchd.log</string>
<key>StandardErrorPath</key>
<string>/tmp/launchd.log</string>
-->
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment