Backup your CiteULike library using MongoDB and Ruby

Well, that was easy.

#!/usr/bin/ruby
require "rubygems"
require "mongo"
require "json/pure"
require "open-uri"

db  = Mongo::Connection.new.db('citeulike')
col = db.collection('articles')
j   = JSON.parse(open("http://www.citeulike.org/json/user/neils").read)

j.each do |article|
  article[:_id] = article['article_id']
  col.save(article)
end

2 thoughts on “Backup your CiteULike library using MongoDB and Ruby

  1. Fergus Gallagher

    Just to note (for others) that this isn’t really a proper backup as there isn’t a way to get the data back into CiteULike. A much better way would be to simply download the BibTeX. This has many advantages, especially that it can be used to restore your library (though not PDFs). SyncUThink (q.v.) is a good way to backup your PDFs.

    1. nsaunders Post author

      Right, backup is not the correct term: perhaps “partial record of your library” would be better. I think it’s a fun and useful “quick hack”.

Comments are closed.