I adjusted the original script to use that specific administrative page. Also, I made the script read in a password file, instead of giving sensitive information on the command line, which makes it show up in the process list. This might be an issue, since backing up several large calendars takes a while.
{code=ruby}
#!/usr/bin/ruby
=begin
$Id: gcal_backup.rb 109 2010-10-03 17:46:07Z visser $
Backup all Google Calendars in a educational domain.
Make sure the used account has admin rights, and that
this user is subscribed to all calendars that need to
be backupped.
Based on idea from Matthew M. Boedicker <matthewm@boedicker.org>.
=end
require 'rubygems'
require 'mechanize'
$VERBOSE = 1
outdir, cred_file = ARGV
unless [outdir, cred_file].include?(nil)
credentials = open(cred_file, "r").gets.split
domain = credentials[0]
username = credentials[1]
password = credentials[2]
time = Time.new
agent = WWW::Mechanize.new
agent.get("https://www.google.com/a/#{domain}/ServiceLogin?service=CPanel&passive=1209600&continue=https://www.google.com/a/cpanel/#{domain}/Dashboard&followup=https://www.google.com/a/cpanel/#{domain}/Dashboard") do |p|
p.form(:action => "https://www.google.com/a/#{domain}/LoginAction2?service=CPanel") do |f|
f.Email = username
f.Passwd = password
agent.submit(f)
agent.get("https://www.google.com/calendar/hosted/#{domain}/exporticalzip").save_as("#{outdir}/#{domain}_#{time.strftime('%Y-%m-%d %H%M')}.zip")
end
end
else
puts "Usage: #{$0} destination_dir credentials_file\nCredentials file should have 'domain username password' on first line"
end
{code}
|