Syncing contacts and calendars using Baikal on your own web server

To keep contacts and calendars up-to-date between multiple devices well-known cloud services like Apple iCloud or the Google services are often used.

It’s no doubt that this is a very comfortable solution – but in my opinion you shouldn’t place trust in public cloud services. I personally avoid cloud services and try to host all services on my own servers.

BYOC (Bring your own cloud)

BYOC (Bring your own cloud)

Using the CardDAV and CalDAV protocols contacts and calendars can be synchronized. There are plenty of open source applications that implement these protocols – including OwnCloud and Baikal. While OwnCloud is an all-inclusive software environment to host your private cloud Baikal offers only CardDAV and CalDAV synchronization – exactly what I was looking for.

CardDAV and CalDAV are open standards that are implemented by a plenty of applications and devices including:

  • Apple iOS (Version 4 or higher)
  • Apple iCal, Adressbook
  • Blackberry Geräte (Version 10 or higher)
  • Evolution
  • Microsoft Outlook and Mozilla Thunderbird (each with addons)
  • Android with CardDav-Sync (Free) / CalDav-Sync

Baikal is published in several versions:

  • Flat package – installation using FTP, for managed web servers
  • Regular package – installation using SSH or FTP, for root servers/vServers
  • Bleeding-edge package – installation using SSH and GIT, made for developers
Baikal-Dashboard

Baikal-Dashboard

I installed Baikal on one of my web servers and choosed the first version because I don’t have a SSH connection to this system.

On managed web servers it is possible that problems arise – e.g. because some authentification mechanisms aren’t available or “characteristics” of the particular hoster have to be considered.

I had to consider the following for my hoster (All-Inkl):

Modifying the original .htaccess file

Before the software installation I had to add the following lines to the .htaccess file:

#Use PHP 5.3 and set some PHP flags
AddHandler php53-cgi .php
php_flag magic_quotes_gpc off
php_flag output_buffering   on

The first code line forces the web server to use PHP version 5.3 – this version is a strict requirement for Baikal. The other two code lines set two PHP configuration values that also need to be modified because authentification issue and other program errors will occur.

If the .htaccess file isn’t modified the installation tool aborts with the following errors:

Warning: Unexpected character in input: '' (ASCII=92) state=1 in ...
...
Warning: Unexpected character in input: '' (ASCII=92) state=1 in ...

Modifying the authentification method

Digest authentification isn’t available on the most managed web servers but also basic authentification isn’t working – depending on the software configuration of the web server (this was working fine in several tests using VMs). Some clever developers have released a workaround for this issue: [click me!].

The folder paths (mentioned in steps 7 and 8) have changed in Baikal 0.26:

  • baikal/Core/Frameworks/SabreDAV/lib/Sabre/DAV/Auth/Backend/ is now baikal/vendor/sabre/dav/lib/Sabre/DAV/Auth/Backend
  • baikal/Core/Frameworks/SabreDAV/lib/Sabre/HTTP/ is now baikal/vendor/sabre/dav/lib/Sabre/HTTP/

This workaround should also help when using other hosters – in my case this also worked for my All-Inkl web server.

After applying the workaround you’ll have to select digest authentification in the baikal settings menu because the workaround module has been enabled for digest authentification in the source code. A tiny little blemish – but who cares? 😉

Replacing the original .htaccess configuration file

In the linked article the .htaccess file is replaced again – I modified the file for my All-Inkl web server like this (mentioned PHP flags and removed 1 redirect):

...

#PHP53, All-Inkl
AddHandler php53-cgi .php
php_flag magic_quotes_gpc off
php_flag output_buffering   on

# iOS
RedirectPermanent /.well-known/caldav http://servername.tld/cal.php
RedirectPermanent /.well-known/carddav http://servername.tld/card.php

The last two code lines are defining a redirect so that contacts can also be synchronized with iOS devices. iOS also uses the sub folder principals/benutzer for synchronization (the folder name is addressbooks/benutzer actually)

After employing these tricks Baikal is working like a charm on my managed web server.

Synchronization under Android

I recommend CardDAV-Sync for synchronizing contacts with Baikal under Android. The application’s price is 1,90 € – but there is also a free version.

For sharing calendars and ToDo lists (that need to be activated in Baikal before) the same developer created the CalDAV-Sync application – it costs 2,59 €. There is no free version of this application – but it’s worth it in my opinion.

The applications are similiar to each other – there is a configuration assistant that created the appropriate system account for synchronization. You need to use the following URL schema (examples):

  • Default calendar, user max: http://servername.tld/baikal/cal.php/principals/max
  • Calendar with ID business, user paul: http://servername.tld/baikal/cal.php/principals/paul/business
  • Default addressbook, user john: http://servername.tld/baikal/card.php/addressbooks/john/default
  • Addressbook with ID customers, user bill: http://servername.tld/baikal/card.php/addressbooks/bill/customers

Tip: The server name needs to be changed depending on your configuration (server name, sub-domain, other folder name,…)!

Both applications are currently beta but are working reliable. I could not discover any data loss or application aborts. The developer recommends to create backup once in a while.

Synchronization with iPhone, iPad and iPod

While you have to update the CardDAV and CalDAV functions with cost under Android these functions are part of the core functionalities of Apple iOS (starting with version 4). Here it is sufficient to add a adequate account in the following menu:

Settings > Mail, Contacs, Calendars > Add Account > Other > Add CardDAV Account / Add CalDAV Account

The URL format is different here:

  • Default calendar, user max: servername.tld/baikal/cal.php/principals/max
  • Calendar with ID business, user paul: servername.tld/baikal/cal.php/principals/paul/business
  • Defaul addressbook, user john: servername.tld/baikal/card.php

Tip: The server name needs to be changed depending on your configuration (server name, sub-domain, other folder name,…) – make sure you applied the .htaccess rewrite rule (see above)!

Leave a Reply