Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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