Merging calendars from multiple sources

/Home /Journal /Services /Projects

Recently started to organize my stuff and decided to include the calendar, the problem is. I have multiple calendars to follow, so i’ve setup a Radicale container with Vdirsyncer to synchronize them all into my personal one, this way my wife will be able to check when we can go on holiday based on staff schedule and then schedule family events on personal calendar so that i can reserve those days, she will also be able to sync her own work calendar.

I started by creating a folder, on the host server, which will contain all Radicale and Vdirsyncer configuration and data.

mkdir radicale radicale/vdirsyncer

Radicale config file, let’s name it radicale-config:

#Optional authentication method
#the users file can be generated with htpasswd -b -c /radicale/users username password
#this tool is part of apache2-utils package
[auth]
type = htpasswd
htpasswd_filename = /radicale/users
# encryption method used in the htpasswd file
htpasswd_encryption = md5
# Average delay after failed login attempts in seconds
delay = 1

[server]
hosts = 0.0.0.0:5232, [::]:5232
max_connections = 20
# 100 Megabyte
max_content_length = 100000000
# 30 seconds
timeout = 30

[storage]
filesystem_folder = /radicale/collections

Vdirsyncer config file, let’s name it vdirsyncer-config:

[general]
status_path = "~/.vdirsyncer/status/"

#Calendar's to be paired
[pair my_calendars]
a = "my_personal"
b = "my_work"

#Because one of the calendars is a read-only calendar it doesn't contain collections
#in case you want to sync two caldav collections = ["from a","from b"]
collections = null
#if you want to sync metadata
metadata = ["colors"]

#Calendars configuration
[storage my_personal]
type = "caldav"
url = "https://terramoto.xyz/caldav/"
username = ""
password = ""

[storage my_work]
type = "http"
url = "https://workurl.com/Calendar/be599e25-9d00-fbeafcd5552b"

Now, time to build the docker image let’s create a file named Dockerfile with the following content:

FROM python:3.7.14-alpine3.16

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade radicale
RUN python3 -m pip install --upgrade vdirsyncer
RUN mkdir /radicale

COPY radicale-config /radicale/config
COPY vdirsyncer-config /radicale/vdirsyncer/config

RUN crontab -l | { cat; echo "0 1-23/2 * * * vdirsyncer --config /radicale/vdirsyncer/config discover >/dev/null 2>&1"; } | crontab -
RUN crontab -l | { cat; echo "0 */2 * * * vdirsyncer --config /radicale/vdirsyncer/config sync >/dev/null 2>&1"; } | crontab -

EXPOSE 5232

CMD python3 -m radicale --config /radicale/config

Build the image:

docker build .

this should output an id associated with the image.

Run the container with the image

docker run -p 5232 --name radicale -v LOCAL-PATH:/radicale -v LOCAL-PATH/radicale/vdirsyncer:/root/.vdirsyncer/ IMAGE-ID-HERE

Setup your Radicale calendar on your device and it should sync with the other calendars you’ve setup on Vdirsyncer.