Skip to content

Commit

Permalink
Make Google contact backups work again.
Browse files Browse the repository at this point in the history
TODO: genericise this script, removing paths to my backup storage location etc,
so it's more useful for other people.
  • Loading branch information
bigpresh committed Jan 26, 2012
1 parent 9597a02 commit d0de890
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions backup-google-stuff/backup-google-stuff.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use common::sense;
use DateTime;
use File::Copy;
use WWW::Contact;
use WWW::Mechanize;
use YAML;

Expand Down Expand Up @@ -34,14 +35,18 @@
':content_file' => "$backup_dir/calendar_$ymd.ical.zip"
) or warn "Failed to fetch ical export ZIP file";

# And now, export all contacts, both in Google's CSV format and vCard format,
# for ease of later use:
for my $format (qw(VCARD GMAIL_CSV)) {
$mech->get('https://mail.google.com/mail/contacts/data/export'
. '?exportType=GROUP&groupToExport=%5EMine&out=' . $format,
':content_file' => "$backup_dir/contacts_${format}_$ymd"
) or warn "Failed to fetch contacts as $format";
}

# For contacts, we used to be able to get Google's CSV format and standard vCard
# format, but they changed how their export system works. Now, we need to use
# WWW::Contact to get contact data. It might not be in a format we can
# immediately import with other stuff, but at least we have the data.
my @contacts = WWW::Contact->new->get_contacts(
$account->{username}, $account->{password}
) or die "Failed to fetch contacts!";

YAML::DumpFile("$backup_dir/contacts_$ymd.yml", \@contacts);;



# Finally, Google Reader subscriptions:
$mech->get('http://www.google.com/reader/subscriptions/export',
Expand Down

0 comments on commit d0de890

Please sign in to comment.