03 March 2009

Backing up Google Reader subscriptions

Automatically backing up Google Calendar is easy with the private ical urls. However Google Reader requires you to login before you can download your subscriptions in opml format. You can script this using wget:

wget "https://www.google.com/accounts/ServiceLogin" --no-check-certificate --save-cookies="/tmp/gcookie" --keep-session-cookies --output-document=/dev/null

GALX=`grep "GALX" /tmp/gcookie | cut -f 7`

wget "https://www.google.com/accounts/ServiceLoginAuth" --post-data="service=reader&Email=joe@gmail.com&Passwd=mypass&GALX=${GALX}&PersistentCookie=yes&continue=http://www.google.com/reader/view" --no-check-certificate --load-cookies="/tmp/gcookie" --save-cookies="/tmp/gcookie" --keep-session-cookies --output-document=/dev/null

wget "http://www.google.com/reader/subscriptions/export" --no-check-certificate --load-cookies="/tmp/gcookie" --output-document="subscriptions.xml"