Converting to Nextcloud Contacts and Calendars

I recently bought a Syncloud Cloud server, primarily so that I, my girlfriend and my band could all have large dropboxes and shared dropboxes without each having to pay large regular fees to a cloud company. The dropbox facilities the Nextcloud server on it provides are similar to those of Dropbox, but Nextcloud also has a wide range of apps that can be installed to provide more cloud facilities.

Among them are Contacts and Calendar apps, which I decided to install and convert to in order to reduce the amount of information that Google can trawl about me. To consider them working I needed to get both to operate in the Nextcloud web interface, Thunderbird (on Windows, but that is probably not relevant) and Android phone and tablets.

The Contacts app was reasonably easy to switch to – on my second attempt. First time I tried what seemed like the easy way, to export all my contacts from Google Contacts and import them into Nextcloud Contacts. It did kind of work, but a lot of information ended up in the wrong fields and things like photos didn’t come across. Googling (or, to be precise, DuckDuckGoing) gave me the impression that I would do better to manage the conversion on my phone, which turned out to be correct.

To carry the conversion I needed to buy and install 2 apps, DAVx5 and Copy Contacts. The first carries out synchronisation between WebDAV apps (like Nextcloud) and Android, and the second is just for the one off job of copying the Contacts. The instructions to set DAVx5 were straightforward and, after using Copy Contacts to copy my Contacts list across on the phone, the contacts appeared in Nextcloud, with no information obviously missing. At that point I removed the sync between my phone and Google Contacts and used the Copy Contacts app to delete the Google Contacts list from my phone.

After a bit of editing, I put DAVx5 on my Android tablet as well, and it initially looked like it had worked, but some edits I had made to Contacts on the phone and in Nextcloud didn’t appear. The reason was that I had left the Google Contacts list on the tablet and it was confused about which it was showing, as both sets had the same IDs for the entries. To fix it, I just installed Copy Contacts and used it to delete the Google list.

To synch the contacts to Thunderbird I needed to install 2 add-ons, Provider for CalDAV and CardDAV, which provides the back end synchronisation to WebDAV, and TbSync, which controls the sync in TB. I had a little bit of trouble getting it to recognise the server, but it did work after several attempts (I’ve no idea what I did different). The sync to and from the address book was then straightforward. One thing I did need to do was to change an advanced setting within Thunderbird,

network.cookie.same-site.enabled = false  

Calendars were a little more trouble. The export from Google was easy enough, once I found out how – Settings/Settings/Import and Export. Export zips up and downloads all of the calendars in iCal format. Importing an ics file into Nextcloud should be simple, but there seems to be some problem with the server getting overwhelmed (my guess is the operation is too multi-threaded, but I haven’t checked the code), with the result that it failed to import most of the entries in my most important calendar (which runs back to 2007).

I decided to try it the other way around, and instead load the calendar into Thunderbird and synch it the other way. Importing it into TB was very easy. When TbSync tried to carry out the synchronisation, however, it ran into similar problems again – putting a couple of years worth into Nextcloud, but then only managing a handful more entries (usually only one) on each synch.

This obviously wasn’t going to work, so I cleared the Nextcloud and Thunderbird calendars out and decided to start again. What I decided on this time was to split the ics file up, so that I could carry out a series of smaller imports. I did this using LINQPad and Ical.Net from NuGet. My script was, roughly,

Calendar cal;
using (var s = new FileStream(@"mycalendar.ics", FileMode.Open)) {
    cal = Calendar.Load(s);
}
cal.Events.GroupBy(e => e.Start.Year)
    .Select(e => new { Year = e.Key, Count = e.Count() }).Dump();

for (var year = 2007; year <= 2019; year++) {
    var newCal = new Calendar();
    foreach (var tz in cal.TimeZones) newCal.TimeZones.Add(tz);
    newCal.Events.AddRange(cal.Events.Where(e => e.Start.Year == year));
    var data = new CalendarSerializer().SerializeToString(newCal);
    using (var f = new StreamWriter($@"mycalendar-{year}.ics")) { 
        f.Write(data);
    }
}

Each of the resulting files could be imported into Nextcloud. One or two gave messages about a small number of failures, but running the import on them again got them fully imported.

The problem then was that synching them with Thunderbird only seemed to work one way, from TB to Nextcloud, but nothing would appear from the Nextcloud calendar in TB. After a lot of messing around, I finally discovered that the trick was simply to shut down and restart TB, and after a few seconds pause all of the entries from the calendar appeared in the Lightning page.

DAVx5 synched the calendars to the various phone and tablet calendar apps with no trouble at all.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.