Import calendar feature - once off or does it update?

I’ve got a hopefully easy question -

I have a 2 nextcloud calendars: work and personal.

I also have to keep a Google calendar for work I do with others.

If I use the import function on Nextcloud calendars, it imports a vcs/ics file.

When I import the cal file with, e.g. 10 appointments, I presume it will not update it when it now has 15?

Thanks.

Afaik, a subscribed external read-only calendar resource is not updated instantly but by a background cron job as described here. I have in mind that the resource will be updated not more than once a week after it has successfully been loaded.

Hi @j-ed,

Thanks. So just to confirm I understand - the (in this case Google) calendar file will be updated, at a rate defined by the Nextcloud cronjob?

Even when events have been added after that import?

If that’s the case, when looking in Settings>Administration>Basic settings> I’ve setup the cronjob as follows:

Use system cron service to call the cron.php file every 15 minutes. The cron.php needs to be executed by the system user “www-data”.

And I’ve just confirmed (using the “Last job ran XXXX ago.”) notification that it is running every 15 mins.

Based on the current documentation you should execute the cron job at least every 5min. Nextcloud executes internal jobs automatically if necessary.

Even though cron jobs run very often (which is good anyway), calendar subscriptions get refreshed by default every week - unless the subscription says otherwise.

https://github.com/nextcloud/server/pull/19392 introduces an admin setting to lower this interval.

1 Like

Can you please shed some light on how this parameter could be changed in the future, by setting a new configuration parameter, via a web dialog or by executing an occ command?

This looks to me like there might be a misunderstanding:
If you IMPORT an icalendar file - nothing will be refreshed.
You need to subscribe to the webcal-Link of the google calendar.
@j-ed and @tcit are referring to a subscription not an import of an *.ics-file

2 Likes
occ config:app:set dav calendarSubscriptionRefreshRate --value=“%value%"

EDIT : It will probably be documented in https://docs.nextcloud.com/

2 Likes

Based on the commit log I assume this should work in 18.0.4? In my case, with 18.0.4, after having set calendarSubscriptionRefreshRate to PT1H, it still doesn’t seem to refresh at all, though.

I have a google calender subscribed to via an https://calendar.google.com/calendar/ical/my-email/private-id/basic.ics URL in my nextcloud calender but it hasn’t refreshed in a > 12 hours, i.e. it still shows test appointments I had deleted ~ 16h ago and doesn’t show new appointments created in the same timeframe.

There’s nothing in the nextcloud log and cron jobs are indeed running at a 5min interval. Verified that by setting a bad value for calendarSubscriptionRefreshRate in which case it logs an Sabre\VObject\InvalidDataException: The supplied iCalendar duration value is incorrect every 5 minutes.

Syncing the same feed in Thunderbird/Lightning shows the google calender as it actually is at this point in time, so I assume this is not a problem on the google side of things.

Have you double-checked that the changed value has been taken into account? As far as I remember the following command syntax need to be used to set the value:

occ config:app:set dav calendarSubscriptionRefreshRate --value=“PT30M”

My command was indeed missing something. The docs have been updated : https://docs.nextcloud.com/server/18/admin_manual/groupware/calendar.html#refresh-rate

1 Like

Actually, I think the reason is elsewhere. I just deleted the calendar subscription and added it back in while having an eye on the log. Turns out there’s an exception

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'lastoccurence' at row 1 at <<closure>>

(full log here) The calendar still appears on nextcloud, but I guess this will block/prevent any further updates?

If I read the actual SQL statement in the debug log correctly, lastoccurence is actually -1942185600 in this case and the event is some yearly birthday event (which I guess never ends).

Meanwhile, I have narrowed it down further: I have some events in my google’s .ics file where the DTEND entry looks like this:

DTEND;VALUE=DATE:18991230

These seem to be birthday reminders from contacts (just a handful) and the date is obviously crap.
But I suppose the nextcloud importer should still handle that in a controlled fashion…

So, given that the respective table’s column is an unsigned bigint, I’ve simply added a < 0 check
for $lastOccurrence in CalDavBackend:getDenormalizedData

if ($lastOccurrence < 0) {
    $maxDate = new DateTime(self::MAX_DATE);
    $lastOccurrence = $maxDate->getTimestamp();
}

This causes the importer to continue w/o exception and subsequently the PT30M refresh to work, too. I guess I’ll create a bug report.

1 Like

I’ve simply added a < 0 check
for $lastOccurrence in CalDavBackend:getDenormalizedData

This worked brilliantly for me! I can now re-sync my Google calendar.

Do you have a link to the bug report so I can follow it there?

Even though this post is rather old, I came across it when attempting to export data from a Nextcloud server. This calcardback little ditty is a treat!

It will export/backup both contacts and calendar with pure perfection! Even if one is unable to access Nextcloud via the web interface for any reason. Brilliant!

Here’s the link for calcardback:

https://codeberg.org/BernieO/calcardbackup