Please note: This article has been contributed by a user.
Contents |
After searching for a while I finally figured out a way to keep my mac at home in sync with my mac at work.
I first started with a usb-stick to copy the Database.xml file manually every time I had to switch. That rapidly became a pain.
So I started looking into SVN which I already use frequently for my work. I assume for this tutorial you have a working subversion server and the svn client installed on your mac. Mine is configured in the most basic way, it uses svn+ssh.
So let's get started.
First we quit things so we can work with the Database.xml file without things crashing.
Now open terminal and enter following commands:
Everything between [ ] is supposed to be customized for your settings
cd ~/Library/Application\ Support/Cultured\ Code/Things
This brought you to the directory which contains your Database.xml file
svn import . svn+ssh://[svnUser]@[domainname]/[svndir]/things/trunk
You'll get prompted for your password at least once, maybe more. This is your svn user password
You should get some output telling you the import was successfull
With this command you imported your Database.xml into the svn, all the above you only have to do once.
We need to do this on all the macs we want to keep in sync. Now we need to get it out again so we first move the Database.xml file to the desktop so we have a backup in case something goes wrong
mv Database.xml ~/[macUser]/Desktop/
Now we go and check the file back out from the repository
First, let's change the directory up one level. This is because we imported the file into the trunk directory in the repository. Now we want the file back but we don't want the trunk directory to be created in the local filesystem
cd ..
Now let's check the trunk directory out as "Things" directory
svn co svn+ssh://[svnUser]@[domainname]/[svndir]/things/trunk Things
You may get prompted for your password once, maybe more. This is your svn user password
You should get some output telling you the file checked out. Now we do a quick check if the Database.xml file is back in the Things dir.
ls Things/
the output should have Database.xml in there. if not you did something wrong.
So now we have a working svn, to update the file on the server you just enter.
cd ~/[macUser]/Library/Application\ Support/Cultured\ Code/Things svn commit -m " "
to get the file from the server you do the following
cd ~/[macUser]/Library/Application\ Support/Cultured\ Code/Things svn update
Now we are going to automate this process.
First we need to automate the password process.
1. Open up terminal on your local machine and type:
ssh-keygen -t rsa
2. Accept the default location
3. Type in the passphrase twice
4. Then copy the public key to the remote server using:
cat ~/.ssh/id_rsa.pub | ssh username@myserver.com "cat - >> ~/.ssh/authorized_keys"
for Leopard users go to the next step. Tiger users, go and download SSHKeychain at SSHKeychain
Now we get to the nice part. We are going to use applescript to have a one click way of updating the Things Library svn
I made 3 scripts myself, 1 to commit the Libray, 1 to update and one I call now instead of using the shutdown command.
download and edit following scripts
3 Things commit and shutdown mac
When you edited the files, save them.
Now have fun using these scripts for keeping your Things Library in sync.
Alternatively, you may download and install simple shell scripts rather than AppleScripts. Please edit svn line in the "checkout_things.command" script to point to your repository after downloading and unpacking. You can put the scripts wherever you like. I keep them in ~/bin/ directory with links (aliases) on the Desktop. Once clicked they will run in the Terminal.app and will give you the results feedback even if you don't have Growl installed. They are also easier to set up for automated execution using cron. As the scripts use "osascript" command to quit and activate Things.app, so please make sure you have this command available on your machine. I am not sure if it is installed by default or comes with Developer Tools, which I have installed on every machine here.