In an effort to minimize my downtime when the funny noises this MacBook Pro is making finally amount to something – I’ve wired up a git repository to OS X’s native launchd service. The git repository hold all of my active projects – whether development projects with their own repos, research projects, consulting project. Everything.
Right now, there’s a Mac mini holding the shared repo with a MacBook Pro and a MacBook Air pushing and pulling to it.
- Set up SSH keys the laptops and server (I like GitHub’s instructions)
- Set up the repo on the server
git --bare init
- set up a repo on both client macs
git add .
git commit -a -m "initial commit"
- create the active-projects.sh backup script in your ~/Documents directory
git pull origin master
git add .
git commit -a -m "Active Project Sync - $DATE"
git push origin master
- make active-projects.sh executable
chmod +x project-backup.sh
- Make the active-projects-backup.plist file for launchd
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
- save the active-projects-backup.plist file to ~/Library/LaunchAgents and load it up
launchctl load ~/Library/LaunchAgents/active-projects-backup.plist
- Now, whenever a change is made in your ~/Documents/Projects – it will be automatically committed to the git repo and propagated to all computers connected to that repo. Like magic.
Thanks to culturedcode’s instructions for syncing Things with git & Launchd.