A Guide to Backing Up Pinboard

I’m a huge fan of the Pinboard, a web-based bookmarking service. I never understood web-based booking when it was big and why everyone used it, but as my reading, writing, and speaking has increased, I’ve realized the value of having an everything bucket to toss everything and anything interesting into.

Now much of my workflow for things I do is dependent on Pinboard. When I start a presentation, I go to Pinboard and open up all my tags that are relevant to that topic. When I write on Behind Companies, I’m often reminded of things I previously read – Pinboard makes it easy to find those articles.

Even better, for $25 per year, Pinboard offers an archival account, which will store a copy of pages you bookmark to combat link rot, where stuff disappears over time.

Recently, I’ve also integrated other services into Pinboard using the fantastic ifttt. I save favorited YouTube videos, starred Google Reader items, and liked Instagram photos to Pinboard. It’s become my brain.

So with so much dependency on all this, I knew I needed to save this stuff. If Pinboard disappeared tomorrow, I need a way to access this stuff I’m saving. Maciej Ceglowski, developer of Pinboard, gives you the option at any time to export all your items as HTML, XML, or JSON. Data portability is good. However, there’s no automated option to do this.

So I came up with a way to automate everything. This is an idiot’s guide to do it, since I’m by no means a pro at this stuff – I just poke around until I can make it work.

Requirements

  • Web Server where you can run CRON jobs (most basic web servers can do this)
  • ifttt Account (Free)
  • Dropbox

Step 1 – Set up a CRON job on your web server

This step will set up an automated command to download all of your current Pinboard data to an XML or JSON file on your web server.

A CRON job is an automated way to run commands on a web server. The Pinboard API lets you send a command that will return all of your data.

Log in to your web host’s control panel, and you should be able to find somewhere to enter CRON jobs. You can choose how often to run it, I run mine nightly. Use this command, and fill in the variables in brackets (be sure to remove the brackets).

curl https://[pinboardusername]:[pinboardpassword]@api.pinboard.in/v1/posts/all?format=json -o "[/path/to/backup/directory/on/Webserver/][filename].json"

I chose to use JSON per Maciej Ceglowski’s recommendation that [JSON is probably the easisest to parse] if Pinboard were ever to disappear. If you want to use XML, just remove ?format=json and change the filename to .xml.

Parsing just means that in the future something could take the input and split all the fields into something readable. Think of it as an Excel spreadsheet that can split each field into a column.

Step 2 – Make ifttt copy your backup to Dropbox nightly

So at this point, you’ll have a .json file sitting on your webserver somewhere, http://www.example.com/Pinboard/pinboard_backup.json. For most people this might be enough, but I want an extra layer of backup protection to Dropbox, in case my webserver were to go down as well.

Log in to ifttt, and go to Tasks > Create Task. Your trigger will be Date & Time where you’ll set what time you want to run the script. Then on Dropbox, it will run as grab a file from URL. Just enter your URL and the directory on Dropbox you want to save your file.

And you’re done.

Now I can live with the security that my saved articles. I’m secure knowing I’m a paying user of Pinboard, but nothing is forever, and some day the service will not exist. When that day comes, I’ll have an up to date backup sitting locally and in the cloud on Dropbox.

Update Dec 29, 2011 4:55pm: The question was asked if you can use your API endpoint URL (https://[pinboardusername]:[pinboardpassword]@api.pinboard.in/v1/posts/all?format=json) straight into ifttt. Maciej confirmed that it should work, the problem is that you’re essentially storing your login credentials in a 3rd party service, and you don’t know if they’re storing and transmitting it securely.

So the point is: it’s an ok workaround if maybe you don’t have access to a web server, just make sure you use a unique password.

Update Dec 28, 2012 3:42pm: An issue has popped up regarding passwords in the URL. If you are using special characters, there is a chance that the URL will not work. Consider updating your password to not use special characters.

Another point to consider is that if you append the date to your ifttt upload to Dropbox, your folder could grow pretty big with all the historical files. I recently started using Hazel, an app that lets you set automated actions on folders based on certain conditions. I set up a Hazel action to delete any backups older than 5 days:

Hazel Pinboard backup purge

December 29, 2011