Mai 2010 Archives
+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:
#!/usr/bin/perl # # googlecontacs.get_vcf -- get dump of Google Contacts (as VCARDs) # use strict; use warnings; use WWW::Mechanize; my $USER='XXXXXXX@googlemail.com'; my $PASS='XXXXXXX'; 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->get($start); $mech->field('Email', $USER); $mech->field('Passwd', $PASS); $mech->submit(); # 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: $!"; }