Quick ‘n’ Dirty Dogear Backup
July 31, 2009 Leave a comment
A little bit of a deviation from our usual WebSphere content here, but: if you’re using Lotus Connections in your organisation, you might want a way to backup the bookmarks you save to Dogear locally. Maybe there’s a lot of valuable content in there that you need should it go offline for a few hours, for example. I’m just paranoid, and I always like to have personal backups of anything important to me – which my bookmarks sure are.
So I wrote a quick and dirty Python script that backs up your bookmarks by connecting via the Dogear API and saving them to an XBEL file. It doesn’t support all fields – in particular, in doesn’t currently back up tags, only the title and the URL.
Feel free to take and adapt to your needs (as with all material on this site, this is not supported by IBM in any way and there are no guarantees that this will even work for you). Feedback appreciated as always.
You’ll need to pass in three command-line arguments to the script: hopefully the code is self-explanatory.
#!/usr/bin/python import urllib2 import feedparser import base64 from urllib import quote from optparse import OptionParser parser = OptionParser() parser.add_option("-u", "--username", dest="username") parser.add_option("-p", "--password", dest="password") parser.add_option("-s", "--servername", dest="servername") (options, args) = parser.parse_args() print "<?xml version=\"1.0\"?>" print "<xbel version=\"1.0\">" PAGESIZE = 50 url = "https://" + options.servername + "/dogear/atom?email=" + quote(options.username) + "&access=all&ps=" + str(PAGESIZE) entrieslength = PAGESIZE currentpage = 1 base64string = base64.encodestring('%s:%s' % (options.username, options.password))[:-1] authheader = "Basic %s" % base64string while entrieslength >= PAGESIZE: req = urllib2.Request(url + "&page=" + str(currentpage)) req.add_header("Authorization", authheader) data = urllib2.urlopen(req).read() feed = feedparser.parse(data) entrieslength = len(feed.entries) for entry in feed.entries: print "\t<bookmark href=\"" + entry.link + "\">" print "\t\t<title>" + entry.title.encode('utf-8') + "</title>" print "\t</bookmark>" currentpage = currentpage + 1 print "</xbel>"