Client-side backup of CalDAV calendars

Here is a script to save your own CalDAV calendars from the client. It’s not very elegant (eg it doesn’t discover your calendars but need a static list) but basically works.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
#
# save ICS calendars from CALDAV server
# Ch. Bueche, 4.2.2010
#

# connection info
USER=myself
PASSWORD=mysecret
SERVER_URL=https://my.caldav.com/caldav.php/

# list of server-side calendars to backup
# get these names by looking at “get info” in iCal
CALENDARS=”Priv Work 63B209D5-524F-440F-B492-5B028E6C0298″

TODAY=`date “+%Y.%m.%d”`
BACKUP_DIR=”/data/backup/calendars_$TODAYif [ ! -d $BACKUP_DIR ]; then
    mkdir $BACKUP_DIR
fi

for cal in $CALENDARS
do
    echo “getting calendar $cal”
    curl -s -k -X GET -u $USER:$PASSWORD -o “$BACKUP_DIR/$cal.ics” “$SERVER_URL/$USER/$caldone

echo “all done

Feel free to find out how to get a list of calendars using some smart curl command and CalDAV enumeration.

Pages

Categories

Tags