29 Dec 2012

Trello-Archiver from Scratch

Trello-Archiver is a set of Ruby scripts that allows one to export their Trello board into a CSV, TSV, or XLSX file. It was started by another person on Github.com named Mad_Typist. Early on in the process I sent them a pull request to contribute my changes back… but they don’t seem to be around. Given that, I’ve forked the project and continued to develop it for my own benefit.

Trello-Archiver relies on a few conventions that exist in the Ruby world. 1. Project dependencies are managed with Bundler 2. A semi-recent version of Ruby is used >= 1.9.2

To use the project on a system that isn’t setup for Ruby development, the first step is to install a recent version of Ruby. I prefer to use a tool called Ruby Version Manager for this RVM.

Install a sane Ruby Version Manager along with Recent Rubycurl -L https://get.rvm.io | bash -s stable --ruby

Source the installed script to allow for using RVM this first time w/ this command: source ~/.rvm/scripts/rvm

Future logins will automatically source RVM using your bashrc or zshrc.

The next step is to clone the Trello-Archiver repo from Github.

Then cd trello-archiver and run bundle install. Bundler installs the necessary dependencies for Trello-Archiver. The nice feature about Bundler is that it manages individual projects’ dependencies independently :).

Next, cp config.example.yml config.yml. Config.example.yml is the template for where the authentication credentials are stored along with any default settings.

Open up config.yml with your favorite text editor. Instructions are inclosed in there for how to gather your secret credentials from Trello.com.

First, open https://trello.com/1/appKey/generate in your web browser. Copy the first key as your ‘public key’ and the second (longer) key as your ‘private_key’.

Next we need to enter those values into a special url: https://trello.com/1/connect?key=PUBLIC_KEY_FROM_ABOVE&name=ANYNAME&response_type=token&scope=read,account&expiration=never The two values that need replacing in this URL are PUBLIC_KEY_FROM_ABOVE nd ANYNAME. ANYNAME is a placeholder for any text that you want to use to identify this key, ie it could be TrelloArchiver. Also note that this is authorizing Read-Only access. This way, even if there’s a bug in the software the token won’t allow changes to your Trello information.

Past that value into your web browser and click allow on the confirmation webpage.

The following page that loads has your ‘access_token_key’. Copy this value into your config.yml. Save config.yml and exit to commandline.

That’s it for authentication setup! Make sure to be careful with this config.yml and don’t go adding it to any public git repos ;).

Now for backing things up :). Decide if you want a specific board backed up or all of them.

Let’s backup a single board: -ruby bin/trello_backup.rb -Choose your board by number and hit enter -Enter a filename or not (it defaults to name of board and date stamp) -Defaults to exporting as XLSX (this is easily changed in script).

Now let’s backup all the boards: -ruby bin/trello-autoarchive.rb -Sit back and wait for it to finish! -It’s set to backup all boards with default names and using XLSX filetype.

Caveats: It saves these files into the current folder. Apparently I broke CSV functionality with some recent changes. I’ll get it working again. The spreadsheet structure is what works for me. If you need a different configuration, please let me know and I’ll look into it. Not all info is backed up. For full backup, download your JSON export from Trello. The main thing that I didn’t include in Trello-Archiver is a set of timestamps for when a Card is moved to each List. This could be a future feature if others have a need for it.

Below is a Gist showing the shell commands