+2010-05-26 Mi 15:34

automatic backup of google contacts

After reading this article about backing up the data of google calendars I realized that it might be worthwhile publishing my solution of automatic backups of google contacts. So here goes:
# googlecontacs.get_vcf  --  get dump of Google Contacts (as VCARDs)
use strict;
use warnings;
use WWW::Mechanize;
my $USER='XXXXXXX@googlemail.com';
my $OUTPUTFILE=$ENV{HOME} ."/tmp/google-contacts.backup";
my $mech = WWW::Mechanize->new();
my $start = qq|https://www.google.com/accounts/ServiceLoginBoxAuth|;
my $export_cmd = qq|https://mail.google.com/mail/contacts/data/export?groupToExport=%5EMine&exportType=ALL&out=VCARD|;
# login (to get cookie)
$mech->field('Email', $USER);
$mech->field('Passwd', $PASS);
# get backup of all contacts as VCARDs
$mech->get( $export_cmd, ':content_file' => $OUTPUTFILE );
if ( not $mech->success() )
  die "ERROR: Download of google contacts did not work: $!";

Posted by Andy Spiegl | Permanent link | File under: Linux

Could not open input file: /var/www/spiegl.de/infolinks.php