At the Hadrian Hotel

At the Hadrian Hotel

Thursday, May 10, 2007

Backing up your Google Calendar(s)

I've been mucking about lately with ways to synchronize my various Google Calendars with iCal on my MacBook. The latest method I've been working with is gSync, which seems to now work almost just the way I want. Of course, when you're playing around with your all-important calendar data, you want to make sure that you have a backup (or 2 or 3) in a safe place. To that end, I wrote a quick hack of a csh script to slurp my Google Calendar data to a safe place. The script will keep up to 8 versions of the calendar data for a given day, in case you tend to experiment a bit too much.

I include the script below for any of you who may wish to do the same type of thing (that's all of you, right? - you know what happens when you don't back up your data!). Replace the ALL_CAPS stuff with values that are appropriate for your situation. I hope this helps!


#!/bin/csh

cd DIRECTORY_PATH_FOR_BACKUP_FILES

set today=`date +%Y%m%d`

foreach i (GCAL_1 GCAL_2 GCAL_3 GCAL_4)
foreach j (7 6 5 4 3 2)
set current=`expr $j - 1`
if (-f gc-${i}-${today}.ics.${current}) then
mv gc-${i}-${today}.ics.${current} gc-${i}-${today}.ics.${j}
endif
end
if (-f gc-${i}-${today}.ics) then
mv gc-${i}-${today}.ics gc-${i}-${today}.ics.1
endif
end

set verbose
curl -o gc-GCAL_1-${today}.ics 'GCAL_1_PRIVATE_ICS_URL'

curl -o gc-GCAL_2-${today}.ics 'GCAL_2_PRIVATE_ICS_URL'

curl -o gc-GCAL_3-${today}.ics 'GCAL_3_PRIVATE_ICS_URL'

curl -o gc-GCAL_4-${today}.ics 'GCAL_4_PRIVATE_ICS_URL'

unset verbose


Technorati Tags: , , , ,

1 comment:

bizz said...

you could always try calgoo - www.calgoo.com - ive been using it to access my gcal offline, and thus backs up the data on my local drive. it also imports outlook / icals.

bizz