Leanpub recipe: versioned book backups

Leanpub is a platform for publishing books that gives author control and tools beyond those available from traditional publishers. I used it to test an idea for a Solr Clients book and was able to validate its lack of traction without spending a cent.

One of the great features of Leanpub is that a book can be updated and the readers get notified of the new version. Consequently, it is sometime useful to keep the old versions around for the author and sometimes even for the readers.

This feature is not currently present in Leanpub, but we can add that with a bit of a glue from Zapier - web automation service. This is especially useful if you are using GitHub to edit your book with automatic preview and want a full end-to-end edit-preview experience without having to touch the Leanpub website.

The following recipe will setup the glue for your own book with the results going into your own Dropbox, versioned with date.

  1. For publication version backup, buy your own book. Free copy is fine, as long as you are getting the notification email that includes direct links to published eBook. For preview copies, skip this step.
  2. Copy the link from the publication notification email and keep it handy. These links change sometimes, but they do seem to stay stable for quite a while. For preview, the link is on Preview page at the bottom.
  3. Create an account on Zapier
  4. Copy my recipe (Start Using This) and fill-in your details as below:
  5. Confirm step 1 (Web Hook to Dropbox)
  6. Copy Hook URL given to you by Zapier
  7. Go to your book in Leanpub and find the section called Web Hooks under Settings
  8. There are three options there to connect, but we only care about top two: Post preview webhook and Post publish webhook. Choose which one you want to do first and paste the URL from Zapier into corresponding field. You can come back and automate the other one later by creating another copy of the recipe and getting a new webhook URL to use. Update the settings with the button at the bottom of the page (scroll down to see it). Stay on the page.
  9. Back in Zapier, connect your Dropbox account in the next step (Register if you don’t have one).
  10. Continue on the next (Filter) screen, as we don’t need that
  11. On the next screen, we have a number of steps:
  12. Choose Dropbox directory you want the files to be placed
  13. In the File section, put the direct URL for the format you want from the step 2 above
  14. Leave other fields alone if you want your book to be named slug_date.format where slug is the same value you put in the Book URL field in the Leanpub configuration, date is when preview/publish event happened and the format will be automatically appended from what is supplied by Leanpub when the direct URL is accessed (so, PDF if you are using PDF direct link, etc)
  15. Press Test Web Hook trigger in Zapier, switch to Leanpub and press Test next to the field you filled in step 8 above. If you are a bit slow, Zapier may popup additional dialogue to walk you through the steps. Proceed, until you are successful in getting Leanpub test to register on Zapier.
  16. In the Sample box that now appears in Zapier, press Use this Zap (or similar). A couple of seconds later, your Dropbox account should be updated with the book in the appropriate format.
  17. In the next step, name your Zap and you are done.
  18. Generate a preview or publish new version (without email if you didn’t change anything) and see it show up in your Dropbox next to the test-generated copy.

Variation: If you want to keep only the latest version instead of dated versions, change the fields back in step 14 to allow override file and to not have date in the file name.

Troubleshooting: If your Dropbox suddenly starts getting .txt files instead of expected PDFs or EPUBs, that means the direct URL changed. Copy the new direct URL from a latest email or from configuration screen and update the corresponding Zap field.