DAViCal Calendar Server

I run a local calendar server that allows my family members to share calendars between their devices.

The server is a Raspberry Pi running DAViCal and an additional web interface on top of Apache. More recently, I rebuilt the server using Ansible playbooks for configuration and maintenance. I also created my own certificate authority to allow client devices to connect over SSL.

Aside from my website, this is my longest-running project.

Below are my notes from when I first created the server, updated with some of the knolwedge I now have (and a bit of copy-editing).

the homepage of my family's calendar server

Installation Notes

My current server is configured using my Ansible project, so these notes don’t completely match how my server currently runs, but they should be similar.

DAViCal is a simple Linux calendar server application that runs on top of any standard web server (such as Apache).

There are other CalDAV servers, but I chose DAViCal because I could install it from a repository. Lazy? Slightly, I’ll admit. (You might want to look into the other servers if you want a more feature rich interface or a built in calendar web app).

Several years later, DAViCal has been been pretty reliable, works well with all the devices my family owns, and has an active and helpful mailing list, so I think it was a good choice.

Since I had two Raspberry Pi’s lying around doing nothing, I decided to turn one into a calendar server.

Server

The DAViCal installation notes are pretty good, so I won’t repeat them here.

I installed Apache2 from the Raspbian repositories, and then DAViCal.

A few tips:

Configuring iOS Clients

  1. go to settings > mail, contacts, calendars > add account...
  2. select "other" and then "CalDAV"
  3. enter the server IP or domain, the user account to be used when connecting, the password, and any description you like
  4. Wait, wait, and wait some more! This could take a while! Its the worst part of the process, but don't leave this screen until the error message appears.
  5. When the error message appears, click "cancel".
  6. Go to the advanced settings.
  7. Set the port as 80 (or whatever the web server is on).
  8. Make the account URL look like this: http://[SERVER IP]/davical/caldav.php/[DAVICAL USER NAME] (If DAViCal is installed in your server root directory, remove davical from the URL. Or replace it with whatever your subdirectory is called.)
  9. Hopefully your device should start to load the calendars on the server (unless this is the first device to access the server and there really nothing there yet). When you have a lot of events, this could take some time.

The recent versions of iOS and Mac OS don’t like to authenticate over plaintext (thanks to the DAViCal mailing list for identifying this problem), so you’ll need to configure your server with a certificate. This is relatively easy to do if you follow the guides available online for creating your own certificate authority.

Configuring Other Clients

The built-in Calendars client in Mac OS works similar to the iOS configuration above. There are other desktop clients for other operating systems, but I couldn’t get them to behave as nicely as the iOS and Mac devices.

Note that before start creating events with a new calendar client, it is good idea to check the client’s default settings for event alerts. One Mac my family had kept adding reminders that went off the day before each. Default settings like these can cause a lot of irritation once those reminders sync to everyone else who connects to the server.

Getting a Desktop Client (sort of)

The desktop clients I tried just didn’t work well. So while looking for other ones to try, I found CalDAVzap, an open source CalDAV web application. So I downloaded it and unzipped the file into my web server. After some short configuration (use the readme file, Luke!), I got the client working.

Though I usually dislike web applications, I realized that web applications that you can run on your own server are awesome. This one is really nice, and works just as good as the iOS clients (though slower). Now I have an easy way to access and update my calendar from any device.

Making Database Backups

DAViCal stores everything in a SQL database; it’s a good idea to back this up once and a while.

Review the Backups guide on the DAViCal wiki before you start. The actual backup is as simple as:

sudo -u postgres pg_dump -Fc davical > /home/pi/davical-backup-$(date -u +"%FT%H%M%S%Z").pgdump

(The call to date is not necessary, but gives the backup a filename that includes a date and timestamp.)

Backup Restoration

  1. Follow the installation guide to setup a new server if you are restoring your backup onto a different server.
  2. The database must be empty before a backup can be restored. Carefully run su postgres -c 'dropdb davical' Make sure you don't delete anything important.
  3. Create a new database createdb --owner davical_dba --encoding UTF8 --template template0 davical
  4. Restore your backup pg_restore -Fc -d davical davical.pgdump

Other Notes