If you’re interested in exporting (or backing up) your Google Reader Subscription List you can log into Google Reader, go to Manage Subscriptions, and then Import/Export and then export your subscription as an OPML file (which is basically an XML file.)
If you want to automate this process, there are a few steps involved… I used curl, which is easy, but other tools can also work.
The first thing you need to do is get an Auth code:
curl -daccountType=GOOGLE -d Email=[USERNAME]@gmail.com -d Passwd=[PASSWORD] -d service=reader https://www.google.com/accounts/ClientLogin
Substitute your own Google username for [USERNAME].
Substitute your own Google password[PASSWORD].
Once you do this, you’ll get 3 lines returned, that look something like this:
SID=HFDY49j4ljlkfgdg4tfh03fdkjgldkhfl945840598djglkjh40hi5h... LSID=HFDY49j9ljlkfh03fhgfh565dkjgldkhfl945840598djglkjhhi5h... Auth=HFDY49j7ljlkfh03fdkjgldkhfl945840598djglkjhjgh6640hi5h...
Note: I’ve shortened these (and made them up) but it’s but it’s basically 3 keys SID, LSID, and Auth and their associated values. You’ll need the value for the one labeled Auth.
Now, use curl to request the following:
curl -H "Authorization:GoogleLogin auth=HFDY49j7ljlkfh03fdkjgldkhfl945840598djglkjhjgh6640hi5h..." http://www.google.com/reader/subscriptions/export
Again, I’ve shortened the Auth code (it’s really long!) You’re basically passing the authorization in the header of the request. It should go without saying that the SID, LSID, and Auth should be kept private. (Which is why I just made up a random string in the example above.)
OK, if it all worked, curl returned your subscription list as OPML. Hooray! Also, you just used OAuth, so Double Hooray!
And here’s our shell script, which will download/backup your subscription list as OPML file. (It’s similar to our mysql backup schell script.)
#!/bin/bash DT=`date +"%Y%m%d"` curl -s -o /home/backups/SubscriptionList-$DT.opml -H "Authorization:GoogleLogin auth=HFDY49j7ljlkfh03fdkjgldkhfl945840598djglkjhjgh6640hi5h..." http://www.google.com/reader/subscriptions/export
Each time you run it, it will get the date with the year, month, and day and use it in the name. So %Y%m%d would produce something like 20100816. This should work fine if you run just one backup per day. (And of course you can store it somewhere besides /home/backups/ if you like. cron is your friend here.)
I know that most people believe that Google will not lose their data, or if the day comes they want to export this data, they’ll just go to the site and export it, but this lets you prepare for the day you can’t get to the site and export your data… or the day Google loses it, or deletes it, or whatever.
By the way… I found most of this information in the Google Reader API wiki. It’s nice that Google is providing an API for things, I just wish some of the info was easier to find… as of this post, that’s the only damn page in that entire wiki!
This is all part of my renewed interest in putting my own data into my own hands, and I may be bugging Jason (@plural) a bit more in the future. ;)
Update: Jason reminded us of dataliberation.org, which I’ll discuss in another post. :)
And just for fun: This gem from 2007: Data Loss At Google Reader.
2 replies on “Google Reader Subscription List backup shell script”
The described way is not OAuth.
Details: Authentication and Authorization for Google APIs
Hmmm, so this is Google’s proprietary authorization scheme and not actually OAuth? Why would they do that?