I recently published a server-side script to backup all calendars stored in a Davical server. On request and idea of Bruno Friedmann, here is a script to save your own calendars from the client. It’s not very elegant (eg it doesn’t discover your calendars but need a static list) but basically works.
#!/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_$TODAY”
if [ ! -d $BACKUP_DIR ]; then
mkdir $BACKUP_DIR
fifor cal in $CALENDARS
do
echo “getting calendar $cal”
curl -s -k -X GET -u $USER:$PASSWORD -o “$BACKUP_DIR/$cal.ics” “$SERVER_URL/$USER/$cal”
doneecho “all done”
Feel free to find out how to get a list of calendars using some smart curl command and CALDAV enumeration.
Comments 1
Hi Charles, a nice contribution.
Posted 04 Feb 2010 at 18:07 ¶I would tend to use the –netrc option for curl avoiding to have username and password being visible during the process life. (especially if you use https to keep information secret).
Post a Comment