Backup Google Reader subscription list to OPML automatically

June 6, 2009

If you use Google Reader, here is a script to backup your subscription list (titles and URLs of subscribed feeds) automatically, e. g. from cron or a scheduled task.

Updated Sep 4th, 2010.

Is it just me or was backing up all your data easier in the old days? Back then, you simply copied files from one machine to another. While this principle still holds true, nowadays my data is literally spread across dozens of machines, each requiring a different login mechanism and credentials. I don’t want to back all of this up, but I prefer to do so if 1) it’s easy to do so or 2) the data is hard to regenerate.

Enough talking, it is easy to schedule an export of your subscription list to OPML, so there is no reason not to do it. The attached script takes two parameters (username and password) and spits out an OPML file – obviously, this should probably be redirected to a file. I call it like this:

gr-opml-backup.py myUserName@gmail.com myPassWord > google-reader-subscriptions.opml

Not sure about the system requirements, but my guess is that any version of Python from 2.3 to 2.6 will be fine. All credit should go to gPowered for providing the Google Reader API library for Python and bandie for fixing the script after Google changed something – thanks!

Download script

flattr this!

  • srid

    Are you sure that this script still works for you? I get HTML instead of opml content.

  • Claus

    You're unfortunately right, Google must have changed something. If I find another solution or get time to fix this script I'll post it here.

  • bandie

    Before it did work for me, but now get I 302 Rediraction html page…
    :(

  • bandie

    Solution is: obtain SID, LSID, Auth variables via POST /ClienLogin, than GET /export with header “Authorization: GoogleLogin auth=$Auth”, where $Auth is the string got by 1st step!
    Anything unclear?

  • bandie

    You should insert a line like:
    header['Authorization']=”GoogleLogin auth=%s” % Auth
    under line begins:
    “header['Cookie']=….”

    And replace this line:
    return re.search('SID=(S*)', result).group(1)
    for:
    return re.search('Auth=(S*)', result).group(1)

    And complete some “def” lines…

  • Claus

    Perfect, I have updated the script with your corrections.

Previous post:

Next post: