CardDAV and CalDAV Migration
3 min read

CardDAV and CalDAV Migration

For those unaware, Cloudron is a platform that makes it easy to run web apps on your server and keep them up-to-date and secure. Think SaaS for self-hosted apps. If you don't have a Cloudron yet, head over to our installation instruction and get started with free credits for a VPS through our referral links.

This How-to will cover step-by-step how to migrate existing CardDAV and CalDAV resources.

Cloudron has various apps packaged, which can host address books and calendars providing webdav endpoints for synchronization between clients:

Step 1: Find addressbook and calendar DAV URLs

Since this guide is for migrating resources from one card/cal dav resource to another, first obtain the full URLs to all the resources which should be migrated. Those have to point to the collection directly. The process will not auto-detect any addressbooks or calendars.

If the synchroniziation should be done on behalf of some other user, admins with ssh access can use the Cloudron Ghost feature to impersonate with the target user.

These look usually something like:

CalDAV:
- https://nextcloud.example.com/remote.php/dav/calendars/<username>/personal/
- https://sogo.example.com/SOGo/dav/<username>/Calendar/personal/
- https://radicale.example.com/<username>/88d98cd0-173f-e59d-3da4-eabc13a12eee/

CardDAV:
- https://nextcloud.example.com/remote.php/dav/addressbooks/users/<username>/contacts/
- https://sogo.example.com/SOGo/dav/<username>/Contacts/personal/
- https://radicale.example.com/<username>/b0a1e55b-1bf7-fb36-2762-ad7e5e467184/

For an existing SOGo installation the CalDAV url can be found at:

While for NextCloud those can be found at:

Step 2: Install cloudron-davsync and verify the URLs

We have written a tool to perform the synchronisation and it is tested with the apps Cloudron supports. It can be installed via npm so make sure to have Node.js installed.

$ npm install -g cloudron-davsync

Once that is done, the URLs from the previous step can be verified to work with the credentials:

cloudron-davsync verify \
  --source <url> \
  --source-username <username> \
  --source-password <password>

If successful, it will also list how many items have been found in the collection. This may be used to verify the contacts count in an addressbook.

Step 3: Install your favorite contacts and calendar app

Unless already done, now is the time to install the app to manage addressbooks and calendars on your Cloudron.

Currently Cloudron supports the following apps:

Step 4: Sync addressbooks and calendars

For the final step, simply create the new addressbooks and calendars in the new app and obtain the new DAV URLs for all of them. They may also be verified with the same process outlined in Step 2. Since the syncer will fetch all resources from the source server and pushes them to the destination, it is recommended that the destination addressbooks and calendars are empty.

Time for action! The syncer operates on one addressbook and calendar at a time. So the following command has to be rerun with different arguments for each resource.

cloudron-davsync sync \
  --source <url> \
  --source-username <username> \
  --source-password <password> \
  --destination <url> \
  --destination-username <username> \
  --destination-password <password>

Example output:

$ cloudron-davsync sync [...]
Found 343 items on source server.
Found 0 items on destination server.
Syncing 343/343 [========================================>] 0.0s
Done. 0 failed. 0 invalid.

Any sync errors will be reported and it is safe to rerun the script. A common error is, if an addressbook entry does not contain a valid name property. In such a case fix that contact in the source addressbook and rerun the syncer.

Installing Cloudron

New to Cloudron? Get started for free by running with 3 simple commands on your server. You can also use the referral links on that page to get a free VPS on popular providers like Digital Ocean, Linode and Vultr.

Comments?

Comments/Suggestions/Feedback? Discuss in our forum.