Okay, so I'm obsessed with contingency planning. Maybe it's the fact that I've spent a big chunk of the last ~9 years of my life studying John's Apocalypse as an academic. At any rate, backups are a big deal to me, and for a while now I've been using a combination of Chronosync, Knox (I bought the discount Path Finder + Knox package), and my iPod to make portable backups that go "off site" with me when I'm away. Just in case the house burns down, or the Portuguese ex-cons who ransacked my old place in Somerville manage to find me again in Chicago, I figure I should have some kind of off-site backup of critical files to complement the nightly mirroring I do of my home directory to my ReadyNAS NV+.
Using an iPod for off-site backup is okay, but it's by no means ideal. If something happens to my place and I didn't bring along my iPod, then I'm up a creek. This being the case, I started searching for an online backup solution for my Mac last week. Some Googling quickly turned up BackJack as the preferred Mac option for power users and corporations everywhere, due to its reliability, redundancy, and the ease with which any user can set up an automated background backup of his or her files. BackJack sounded perfect for me (I'm lazy and notoriously unlucky in my dealings with software), but the service's rates were a bit pricey for me.
After more looking around, I eventually wound up at Strongspace, with a starter plan that gets me 5GiB of storage for $15 per month. At any time, I can up the amount of storage to 25GiB ($50/month) or 100GiB ($100/month). Plus, I get all sorts of added services for free with the package, like TextDrive, Connector, and other stuff that I'm never going to figure out how to use. But I just signed on for the backup, so backup is what I'm going to talk about here.
The main thing missing from Strongspace is an easy, automated way to back up your files in the background. But that's where Google comes in again.
Some searching turned up this handy link containing "push this, pull here" instructions that are complete enough to get you most of the way there, but with just enough warts to make you blow an entire afternoon getting it all to work. Nobody else should lose as much time as I did in getting this up and running, so I've put together this set of additions/corrections/clarifications to the instructions so that your experience will hopefully be much more painless than mine.
In a nutshell, the instructions show you a relatively novice user with minimal UNIX command line skills to automatically sync to Strongspace using rsync and cron by walking you through the following steps:
- Generate an ssh key and copy it up to your Strongspace account.Create a special backup directory of symlinks for syncing to Strongspace.Modify an existing Ruby script that will rsync the directories to Strongspace only if you're connected to the Internet, and only if you're not connected via a modem.
In the rest of this post, I'm going to walk you through some of the problems I found with these instructions, so that you don't have to re-invent the wheel.
Set up key-based login
In this section of the instructions, you'll open Terminal.app and generate an ssh key. These instructions tell you to pick a password for the key, but I'd recommend against it. Sure, picking a password is theoretically more secure, because if someone gets their hands on your private key file then they can access your Strongspace account (or any other account that you're using this key pair with). But the scheme as presented just didn't work for me with the passwords—it appeared to work at first, but further investigation and testing revealed that it just wasn't authenticating.
If you want to know more details of why it didn't work, then read the rest of this section. If you don't care, then skip it. The bottom line is that I'm only using this ssh key with my Strongspace account, and the only way for someone to get access to this key file is to have access to my laptop. Since my Strongspace account is just a backup of files off my laptop, then anyone who has my laptop already has everything anyway. So if you're only using the ssh keys for Strongspace then a password is pointless.
Now, for those that want to know why this part of the instructions doesn't work:
The instructions tell you to download and install SSHKeychain. They don't tell you that you must read the "Install" instructions for SSHKeychain and follow them to a "T." If you just download the program, copy it your Applications folder, and then run it, it won't work right. At the very least, you have to log out and then log back in once you've got it up and going, in order to set certain environment variables. (The fact that I didn't RTFI cost me about 30 minutes of troubleshooting.)
Once you get SSHKeychain properly installed and get your ssh keys registered with it, then you'll be able to scp and rsync to Strongspace without having to type a password. SSHkeychain will automatically get your private key password out of Apple's Keychain utility, saving you from ever having to type it in… unless, you're executing those commands from cron and not the terminal.
Once I had everything set up and I thought I was doing backups, I noticed that I was getting system mail from the cron daemon, telling me that rsync had failed to authenticate. So for reasons that I still don't understand, SSHKeychain isn't able to feed your key passwords to rysnc if it's invoked by a ruby script that's running from cron, even when that same ruby script will work flawlessly when run directly from the terminal prompt.
Create a Strongspace backup directory
The only modification I made to his instructions here was cosmetic. I named my Strongspace backup directory .strongspace. The dot in front of the name means that Finder doesn't show it, so my home directory isn't visually cluttered with any non-standard directories.
If you use a dot in front of your backup directory name, then you must remember to change all of the terminal commands and scripts in these instructions accordingly (i.e. replace "strongspace" with ".strongspace" when the reference is to your home backup directory.
Because of the font that's used for the instructions, it's not at all clear on first inspection that the "–exclude" and "–progress" options for rsync need double dashes in front of them. Unless you look closely, these may look like single dashes to you, and you may spend a long time (like I did) trying variants on the command and wondering why none of them work.
Also, if you want to do a test run to see which files will be copied without actually copying anything, you can add the -n switch. You'd do this by adding an "n" to that string of rysnc options, so that it looks like this: -azvCLn
Setting up regular sync
To make the Ruby script work, you'll need to modify it more than he says. Specifically, this line is going to throw an error:
PID = '/Users/jcf/var/run/ss.pid'
This is a leftover line from his own implementation, and you almost certainly don't have a /Users/username/var/run director, much less one with his initials as the username. What I did was change this line to:
PID = '/Users/jstokes/.strongspace/ss.pid'
This way, the little fake pid file is created in my already-existing strongspace backup directory. Theoretically, you could use any directory that you have read/write permissions to.
Because I don't have a /var directory under my home directory, I keep the log file in the .strongspace directory I created. So you'll want to change this line of his instructions:
$ mkdir -p ~/var/log
$ mkdir -p ~/.strongspace/log
So between the original instructions and my corrections/additions to them, someone with very, very modest UNIX command line skills like mine should be able to set up automated background backups to a Strongspace account in an hour or two.