I recently followed a discussion on Twitter after @thomasmonopoly‘s Google account was blocked for unknown reasons, denying him access to the data he’d entrusted Google with.
I casually mentioned that entrusting Google to store all your data without having backups yourself is a bad idea, and @jmrowland enquired as to how you can back up stuff you create “in the cloud” (using Google).
I figured I should share the Perl script I’m currently using to back up my Google contacts, calendar and Google Reader subscriptions, so I’ve uploadedbackup-google-stuff on GitHub.
As I only wrote the script for my own use it’s quite basic and perhaps not particularly user-friendly, but I thought it only fair to share it; if people are interested in it, I may extend it somewhat. I’m fairly sure there are other “backup your Google account” solutions already out there already, though.
Of course, backing up mail from Gmail is trivial as they offer IMAP access; I don’t rely on Gmail so I’ve not bothered with that myself.
EDIT: I’ve seen Backupify recommended as a good solution for backing up your stuff from Google.
I use Gmail as my only e-mail and every few days I fetch all the messages via pop3 and store them locally. I don’t backup my contact list but if I really need I can extract it from the locally stored e-mails.
The GTalk history is not backed up and a lot of my other cloud activity has not been backed up.
I actually thought to start building a desktop application that would allow a user to back their social lide to their desktop. It might also be used to compare your contacts on the various networks and even mash together the contact lists.
Unfortunatelly I don’t have the tuits for this right now.
Would you be interested in trying to build such a thing?
@Gabor – maybe, although my tuit supply is similarly short. It could be a useful tool, though! It looks like Backupify does most of that for those who want their backup to be “in the cloud”, too – although that’s entrusting your data’s safety to another random company, too. I like to control my own stuff :)
Thanks for the script. After all of the kerfufle with Google suspending plus accounts lately, I’ve decided to be a bit more rigorous in my backup regime.
I’ve been fiddling with your script, but unfortunately my perl-fu is weak and I’m not sure what YAML is looking for in the .google-login file. How should that be formated?
Thanks again for the work!
I’ve had some moderate success using your script, but I’m a little stuck.
I think I worked out the YAML issue – my .google-login looks like this:
—
username: foo@google.com
password: application-specific-password
Unfortunately, things aren’t going too smoothly beyond reading the login file.
I keep geting an ical.zip file that contains a .cpgz file that when unzipped contains a .zip file which contains a .cpgz file and so on. I don’t think it’s actually downloading a valid calendar archive.
Then, when the script gets to the contact section I get the following error:
Error GETing https://mail.google.com/mail/contacts/data/export?exportType=GROUP&groupToExport=%5EMine&out=VCARD: Unauthorized at /home/txoof/bin/google-backup.pl line 40
I currently have 2 step authentication turned on and I’ve set an application specific password for the script and I think that’s causing the problem. If I try to login via lynx using an application specific password, I get the following message from the gmail login page:
Please use your account password instead of an application-specific password.
Logging in with my account password shoots me over to the 2-step verification page asking for a numeric token.
Any ideas of a way around this? From what little perl-fu I have, it looks like the script is mechanically logging in via the google web page and quietly failing. Any help you can offer is greatly appreciated.
@Aaron – I’m afraid I haven’t tried Google’s 2-step authentication or application-specific passwords yet – if I get a chance later on I’ll see if it would be easy to adapt the script to work with them. However, from your description, it sounds like the application-specific password isn’t accepted for Gmail, so the contacts download won’t work, and the two-step auth would require you to enter a number presumably sent to you in a text message, so wouldn’t be very useful for unattended backups from a cron job.
I’ve just checked the latest backup it took of my calendar, and I got a ZIP file containing several .ics files, one per calendar, so I’m not sure why yours contains a .cpgz file. As far as I know that’s a gzip-compressed cpio file (somewhat similar to a tarball), I can’t imagine why Google would provide one of those. The script simply saves whatever it gets from Google by requesting http://www.google.com/calendar/exporticalzip – what do you get if you whack that URL into your browser?
You’re correct that the script simply logs in to the Google website using the account details provided, then downloads data.
As well as their own online backup provisions, I also found it useful to create a max compression backup locally, and then to replicate that well-encrypted backup out to the cloud.