How to backup your Google Calendar automatically on a Windows machine

This is a quick and brief example of how to schedule a backup of a Google Calendar on a Windows machine. This technique uses a PowerShell script and the Windows Scheduler.

First you need to get the information required from Google:

  1. Login to Google Calendar.
  2. Under “My Calendars” click the down arrow (outlined in red in the pic below) that’s at the right of the name of your main calendar, the one you want to backup.

Google Calendar Settings

  1. Then click “Calendar settings”.
  2. In the view that appears, scroll down to the bottom, and find the bit headed “Private Address”, see below.

Google Calendar Right Click Position

  1. Right click the green ICAL button under “Private Address”, which provides the URL or web address of your own calendar file which will be something like (NOTE: keep this address to yourself).

Next create a PowerShell script:

The following should be saved in a file (this will use the example file C:\GoogleCalendarBackup.ps1) where the $Source is set to the “Private Address” URL retreived above:

$WebClient = New-Object System.Net.WebClient
$source = ""
$target = "C:\GoogleCalendarBackup.ics"
$WebClient.DownloadFile($source, $target)

Finally create the scheduled task:

  1. Open Start Menu\All Programs\Accesssories\System Tools\Task Scheduler
  2. Select Action\Create Basic Task…
  3. Enter a name and (optionally) a description then press Next.
  4. Select the frequency of the backup and press Next.
  5. Select the details of the backup frequency and press Next.
  6. Select “Start a program” for the Action and press Next.
  7. Browse to the PowerShell executable on your machine e.g. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.
  8. Put -nologo -command “& {C:\GoogleCalendarBackup.ps1}” in the Add Arguments box and click Next.
  9. Review your setting and click Finish.

I ran the scheduled task to ensure that the backup worked then checked that the scheduled task is running for the first few times just to be sure.

NOTE: Retrieving the Google Calendar URL is based upon by Improbulus

Many thanks to Improbulus.


4 Responses to How to backup your Google Calendar automatically on a Windows machine

  1. Jon Archer says:

    Like it, especially having just read this earlier today:

    Impressive how little Powershell you needed too(!)

    • Gary Varga says:

      I’d have to say that PowerShell is one of the best pieces of software Microsoft have ever developed. They spent a lot of time getting together a team with the right experience AND enthusiasm to create it.

      I love that they have considered developers of extensions, system administrators and standard PowerShell users as first class citizens i.e. if it doesn’t work for one of these types it doesn’t go in. This tenet has made it extremely powerful as they will not do things like sacrifice usability for security, the ability to script for ease of programability etc.

      Of course seeing as PowerShell Language now licensed under the Community Promise means that PowerShell can exist on different Operating Systems it will be interesting if some of the experts of other OSes will embrace PowerShell, ignore it as there are good alternatives or snub it on the basis of its origins in Microsoft.

  2. Jon Archer says:

    I suspect that, because other OSs (namely MacOSx and *nix stuff) already have nice terminals a la bash etc. and scripting languages already entrenched in their community PLUS the general anti M$ leanings in those quarters, that uptake outside Windows is unlikely.

  3. Anonymous says:

    I had problems with spaces in the target directory path. I had to use 8.3 notation, that is, C:\WorkTo~1\Dropbox\MyDocu~1\Useful~1\GoogleBackup.ps1. There is probably an elegant work around but this is quick and dirty!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: