Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple cron script to backup a Google Calendar to Amazon S3 (http://pixelcog.com/blog/2014/backup-gcal-to-s3/)
#!/bin/sh
export TZ=America/Chicago
export PATH=/usr/local/bin:$PATH # ensure path to aws exists for chrontab
# uncomment if needed
#export AWS_ACCESS_KEY_ID=ABCDEFGHIJKLMNOPQRST
#export AWS_SECRET_ACCESS_KEY=1234567890ABCDEFGHIJKLMNOPQRSTUV
bucket="my-bucket-name"
gcal_private_key="example.com_b6nffmu1v5v4jehogm9v5anll4%40group.calendar.google.com/private-4463bc3c4777e7d435cc385f9b3573a0"
cd $(mktemp -d 2>/dev/null || mktemp -d -t 'backup') # work around osx silliness
mkdir backup
curl https://www.google.com/calendar/feeds/$gcal_private_key/basic > backup/master-cal-backup.xml
curl https://www.google.com/calendar/ical/$gcal_private_key/basic.ics > backup/master-cal-backup.ics
tar -zcvf backup.tgz backup
aws s3 cp backup.tgz s3://$bucket/calendar-backup/$(date +%Y%m%d-%H%M).tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment