Automatic Ulysses Backups to Dropbox

There’s an old tech-support joke about important data.

Tech: Does this drive have important data on it?
Customer: Thanks for asking, it does indeed.
Tech: Good. I’ll erase it now.
Customer: Nooo! I’ll loose everything!
Tech: If it’s that important, you’ll have a backup.
Customer: What’s a backup?

In short, if it’s on a computer and it’s important, there should always be a backup.

We’ve gotten better about this. Dropbox was the first service to really break through the noise about backups. Since then a multiplicity of cloud-based backup services have sprung up. Now, cloud-syncing is an expected feature in a lot of apps. I’m glad about this. It’s an automatic layer of worry-proofing. But things can still go wrong.

Ulysses uses iCloud for backup and syncing, and I’ve never had any problems with it. But since I use it for all of my writing, I want the files backed up somewhere else. This seemingly simple idea turned into something a bit more complicated than I planned.

The Idea

My plan was simple, backup the Ulysses (and Daedalus) folders to a zip file on Dropbox. This way I’d have my writing in five places:

  1. My computer, in the default location
  2. My computer, zipped into the Dropbox folder
  3. On iCloud
  4. On Dropbox
  5. Inside of a Time Machine vault

The first two are both on the same drive, but having the files zipped up means it’s only one thing to copy off to a flash drive.

Scheduled Backups

Scheduling a backup seems easy enough with the built in tools. The recommended way is to create a Calendar Alarm using Automator. Then schedule it to repeat everyday. It’s an easy way, but if you’re new to Automator and shell scripts it’s not simple. There’s multiple steps, and most importantly, IT DOESN’T WORK!

There’s a bug in MacOS X Yosemite (10.10.3 as I write this) that prevents the Calendar Alarms from running. There’s not much discussion on this. Even Apple’s documentation is very weak on the topic. It seems not many people use this feature. It’s also extremely frustrating.

So with Calendar Alarms out, I needed another way to schedule the backup.

Being a UNIX/BSD based system, MacOS X has a cron daemon. But with it comes the usual cron-based balkiness. Doing some more research, I found that launchd is the scheduling mastermind of the whole mess. It’s also not easy to configure because of the XML .plist files it uses.

But once the .plist is made it’s just a matter of one command to get it working.

The File

The first step is to copy the XML file below, and paste it into your text editor. You’re going to make a few changes so it’ll work on your computer.

The direct download link is here (tar.gz format).

First, replace the three instances of USERNAME with the user name you login with (Lines 13, 14, and 15).

Second, if you’re not using Daedalus Touch, delete line 15:

<string>/Users/USERNAME/Library/Mobile Documents/X5AZV975AG~com~soulmen~dtouch/</string>

Finally, if you don’t have a ~/Dropbox folder, you’ll have to change line 13 to point to a valid location.

Then save the file as plain text to your desktop with the name local.ulysses-backup.plist.

Installation and Startup

Once the file is saved, open a Terminal window, and change to your desktop folder.

$ cd ~/Desktop

Copy the file to the ~/Library/LaunchAgents folder.

$ cp local.ulysses-backup.plist ~/Library/LaunchAgents/

This next step tells launchd to read the file and load the process into the system scheduler.

$ launchctl load ~/Library/LaunchAgents/local.ulysses-backup.plist

No news is good news. You’ll only get an error message if something went wrong.

Usage

This is the best part. We’re done. There’s nothing to keep track of. It just works. Every evening at 8:30 PM (local time) a backup will happen. After that the zip file will be up-to-date with the day’s changes.

In case something does go wrong you can read the log files. They’re at:

  • /tmp/local.ulysses-backup.err
  • /tmp/local.ulysses-backup.out

The .err file is for system errors. The .out file will have all of the command line output from the zip command. If you want to know if the backups are being done, this is the file to check.

Going Farther

Other things you could do:

  • Duplicate the StartCalendarInterval key to have it run multiple times per day.
  • Use a different compression program.
  • Dig deep into the guts of launchd and create a .plist that copies the backup to a flash drive when it’s plugged in.

Enjoy your fresh backups, and I hope you never need them.

One thought on “Automatic Ulysses Backups to Dropbox

  1. I just symlinked the entire folder to my Dropbox folder. It works fine and I even have access to previous versions of individual sheets with the Dropbox webinterface.

    Like

Comments are closed.