Skip to content

Instantly share code, notes, and snippets.

@mmb
Created March 18, 2009 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmb/80915 to your computer and use it in GitHub Desktop.
Save mmb/80915 to your computer and use it in GitHub Desktop.
Google Calendar backup for custom domain
#!/usr/bin/ruby
# Google Calendar backup for custom domain
require 'rubygems'
require 'mechanize'
domain, user, pass = ARGV
unless [domain, user, pass].include?(nil)
agent = Mechanize.new
agent.get("https://www.google.com/a/#{domain}/ServiceLogin?service=cl&passive=
true&nui=1&continue=https%3A%2F%2Fwww.google.com%3A443%2Fcalendar%2Fhosted%2F#{d
omain}%2Fexporticalzip") do |p|
p.form(:action => "https://www.google.com/a/#{domain}/LoginAction2?service=c
l") do |f|
f.Email = user
f.Passwd = pass
agent.submit(f)
agent.get("https://www.google.com/calendar/hosted/#{domain}/exporticalzip"
).save_as("#{user}@#{domain}.ical.zip")
end
end
else
puts "usage: gcal_backup.rb domain user password"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment