User Tools

Site Tools


computing:linux:sync_calendars_contacts

Sync Calendars and Contacts on Linux

https://github.com/pimutils/vdirsyncer

Docs: https://vdirsyncer.pimutils.org/en/stable/index.html

Tutorial: https://vdirsyncer.pimutils.org/en/stable/tutorial.html

Vdirsyncer is a command-line tool for synchronizing calendars and addressbooks between a variety of servers and the local filesystem. The most popular use case is to synchronize a server with a local folder and use a set of other programs to change the local events and contacts. Vdirsyncer can then synchronize those changes back to the server.

However, vdirsyncer is not limited to synchronizing between clients and servers. It can also be used to synchronize calendars and/or addressbooks between two servers directly.

It aims to be for calendars and contacts what OfflineIMAP is for emails.

Example Syncing Zimbra and Nextcloud

This was done on Linux Mint 21 (Ubuntu) and shows a server to server sync of two addressbooks.

It may help to use this, or use it to work out your final config file:

collections = [“from a”, “from b”]

in conjunction with:

vdirsyncer and vdirsyncer discover

mkdir ~/.config/vdirsyncer && cd ~/.config/vdirsyncer

vim config
# Configuration for vdirsyncer
#
# Move it to ~/.vdirsyncer/config or ~/.config/vdirsyncer/config and edit it.
# Run `vdirsyncer --help` for CLI usage.
#
# Optional parameters are commented out.
# This file doesn't document all available parameters, see
# http://vdirsyncer.pimutils.org/ for the rest of them.

[general]
# A folder where vdirsyncer can store some metadata about each pair.
status_path = "~/.config/vdirsyncer/status/"

# Synchronize all collections that can be found.
# You need to run `vdirsyncer discover` if new calendars/addressbooks are added
# on the server.

# CardDAV

[pair Zimbra_NC]
a = "zimbra_contacts"
b = "nextcloud_contacts"
collections = [["Contacts", "Contacts", "contacts"], ["Shared Contacts", "Shared Contacts", "shared-contacts"]]

# Zimbra contacts take precedence in case of a conflict
conflict_resolution = "a wins"

[storage zimbra_contacts]
type = "carddav"
url = "https://zimbra.virtualarchitects.com/dav/"
username = "username@virtualarchitects.com"
password = "zimbrauserpassword"

[storage nextcloud_contacts]
type = "carddav"
url = "https://cloud.virtualarchitects.com/remote.php/carddav/"
username = "nextcloudusername"
password = "ncuserpassword"

# CALDAV

[pair Zimbra_NC_Calendars]
a = "zimbra_calendars"
b = "nextcloud_calendars"
collections = [["Calendar", "Calendar", "personal"], ["Tasks", "Tasks", "tasks"], ["VA Calendar", "VA - Shared Calendar", "va-shared-calendar"]]

# Calendars also have a color property
metadata = ["displayname", "color"]

[storage zimbra_calendars]
type = "caldav"
url = "https://zimbra.virtualarchitects.com/dav/"
username = "username@virtualarchitects.com"
password = "zimbrauserpassword"

[storage nextcloud_calendars]
type = "caldav"
url = "https://cloud.virtualarchitects.com/remote.php/caldav/"
username = "nextcloudusername"
password = "ncuserpassword"
vdirsyncer discover

vdirsyncer sync

Scheduled Sync

crontab -e

# sync every 15 minutes
*/15 * * * * vdirsyncer sync
computing/linux/sync_calendars_contacts.txt · Last modified: 2024/04/13 11:55 by gcooper