While building a test Nextcloud 26 server I realised that Nextcloud 24 was just about to reach end of life with the release of patch 12. Which is a bit of a goof on my part, but then you could argue it's still OK for another month yet.

The minimum version to update to is the current patch for Nextcloud 25, although it probably makes sense to stardardise on version 26 especially if I'm going to be running other servers for people too.

Contents

  1. Plan
  2. Prepare
  3. Nextcloud 25

Plan

The first thing we need to do is look at the dependencies of each version.

Version Linux Apache MariaDB PHP
Nextcloud 24 Ubuntu 20.04 LTS Apache 2.4 10.5.19 PHP 7.4.3
Nextcloud 25

Ubuntu 20.04 LTS, Ubuntu 22.04 LTS

Apache 2.4 MariaDB 10.5, MariaDB 10.6 PHP 7.4*, PHP 8.0, PHP 8.1
Nextcloud 26 Ubuntu 20.04 LTS, Ubuntu 22.04 LTS Apache 2.4 MariaDB 10.5, MariaDB 10.6 PHP 8.0, PHP 8.1, PHP 8.2

While PHP 7.4 is now end of life it' still supported for Nextcloud 25 so we will update this at the same time. There's no need to upgrade any of the other components although if the other Nextcloud instance goes ahead I'll update MariaDB to 10.6 for consistency. The underlined versions are the recommended ones where there's a choice.

So from this we get a sequence of steps

  1. Apply latest OS patches
  2. Apply Nextcloud 24.0.12 patch
  3. Upgrade Nextcloud to version 25
  4. Upgrade PHP to version 8.1
  5. Test
  6. Consider upgrade Maria DB to 10.6
  7. Consider upgrade Nextcloud to version 26
  8. Test

Once we have successfully tested at step 5 we can apply this to the Live instance.

After what happened in Nextcloud lost connection to LDAP server I also need to apply a step 0 and revert the LDAP configuration back to my main domain controller so it matches the Live configuration too, just in case there's any interesting effects with using an old DC.

Prepare

Applying OS patches is just a routine call to apt

sudo apt update
sudo apt upgrade

The test systems have been offline for a few months so there was a little bit of catching up. Reverting the LDAP configuration was also just a case of changing the hostname and port and it worked perfectly.

A full backup is also taken too, just in case something interesting. Since this is a VM I can also take a snaphot as well so a restore is virtually instant.

Also check the free space in your Nextcloud Data directory, eg /srv/nextcloud/data as the upgrade process will also create a backup copy of you Nextcloud application files in there. I would suggest you want at least 700 MB of space in there before you begin. If you have been updating regularly you might want to delete old backups from the update-[instanceid] directory first.

This is all based on the official Nextcloud process which can be found here:

https://docs.nextcloud.com/server/latest/admin_manual/maintenance/update.html

 

Nextcloud 24 patch 12

The first step is to get the instance onto the latest patch of the current version, so we'll be updating from 24.0.7 to 24.0.12. The easiest way to do this is using the build in updater under Settings > Administration : Overview : Version.

Nextcloud 24 current state

Click on the Open updater button and it'll launch the updater process  which will handle everything for us.

Nextcloud updater ready

All we need to do is click the Start update button when we're ready.

Nextcloud updater running

It'll take a few minutes to do its own backup first and then download the upgrade file. It would be nice if it paused at the Enable maintenance mode step for a final chance to warn users to go for a coffee but it will roll straight into to the execution phase.

Switch back to updater

Click on the Disable maintenance mode and continue button and it will return to Nextcloud to continue the update.

Start Nextcloud app update

This will also update all the installed application to their latest versions too.

After it completes it'll redirect back into Nextcloud and we can then return to Settings > Administration : Overview and under the Security & Setup Warnings section we now have two actions to perform

Post install tasks

  • Update the missing fs_parent index in the oc_filecache table
  • Update the missing mounts_class_index index in the oc_mounts table

We can fix both of these by running the occ command on the Nextcloud host

sudo -u www-data php /srv/nextcloud/www/occ db:add-missing-indices

And it should respond with

Check indices of the share table.
Check indices of the filecache table.
Adding additional parent index to the filecache table, this can take some time...
Filecache table updated successfully.
Check indices of the twofactor_providers table.
Check indices of the login_flow_v2 table.
Check indices of the whats_new table.
Check indices of the cards table.
Check indices of the cards_properties table.
Check indices of the calendarobjects_props table.
Check indices of the schedulingobjects table.
Check indices of the oc_properties table.
Check indices of the oc_jobs table.
Check indices of the oc_direct_edit table.
Check indices of the oc_mounts table.
Adding mounts_class_index index to the oc_mounts table, this can take some time...
oc_mounts table updated successfully.

Logging in as my own user everything seemed to be working fine so we look good to go to patch 12 on the live system and also start the upgrade to Nextcloud 25 on the test system.

Nextcloud 25 Upgrade

Now that we've reached Nextcloud 24.0.12, in Administration : Overview : Version we get an option to automatically upgrade to Nextcloud 25.0.6 and the nice big warning about not being maintained any more has also gone away too.

Upgrade to Nextcloud 25 available

Click on the Update version button and a familiar screen should open up.

Nextcloud 25 updater init

And again once it's completed we, err, we have a problem

Upgrade failure

So the apache2 error log (/var/log/apache2/error.log) show that it had run out of space, (which it had!) and then errors in ClassLoader.php. This wasn't recoverable from the occ command line either so given a choice of trying to find which files got messed up during the extract, attempting a Manual Upgrade or reverting back to the snapshot I took at the beginning and doing it again, on the basis of this is a test system and there's no important data at risk I chose to edit reality instead.

VM snapshot restore

5 seconds later and Nextcloud is rolled back and the only indication that something odd has happened is the Security & setup warnings briefly showing that the last background job execution ran 2 hours ago and something seems wrong.

Attempt 2

The second time around, I removed all but the nextcloud-24.0.7.1-[digits] directories from /srv/nextcloud/dtaa/update-[chars]/backup directory with that amazingly dangerous command rm -rf to increase free disk space from 598 MB to 2.3 GB and this time it completed with 1.7 GB remaining.

Nextcloud 25 app update

 

Nextcloud 25 incompatible apps

So that's a bit worrying as it stated all apps have a compatible version before we started the upgrade. Letting it run the application update seemed to go OK and after a few minutes it announced success.

Nextcloud 25 app update OK

Looking at the application list in Settings > Apps the accessibility and video player apps aren't listed at all, which is not surprising as I don't recall ever installing them. Calendar is shown as version 4.3.3 and active, Deck is sown as version 1.8.3 and active, Group folders is shown as version 13.1.2 and active.

It also looks like the expected data is still there in Calendar and Deck although I haven't started using Group Folders yet so can't see if there's an issue there or not. So this is a little weird to say the least.

Security and setup warnings has has gained an entry about PHP 7.4.3 as expected.

Post upgrade warnings

Another call to occ soon fixed the missing indexes.

sudo -u www-data php /srv/nextcloud/www/occ db:add-missing-indices

Check indices of the share table.
Check indices of the filecache table.
Adding additional parent index to the filecache table, this can take some time...
Filecache table updated successfully.
Check indices of the twofactor_providers table.
Check indices of the login_flow_v2 table.
Check indices of the whats_new table.
Check indices of the cards table.
Check indices of the cards_properties table.
Check indices of the calendarobjects_props table.
Check indices of the schedulingobjects table.
Check indices of the oc_properties table.
Check indices of the oc_jobs table.
Check indices of the oc_direct_edit table.
Check indices of the oc_preferences table.
Adding preferences_app_key index to the oc_preferences table, this can take some time...
oc_properties table updated successfully.
Check indices of the oc_mounts table.
Adding mounts_class_index index to the oc_mounts table, this can take some time...
oc_mounts table updated successfully.

So that looks like a success to me.

PHP 8.1 Upgrade

This is the next task, in Tech: PHP 8.1 Upgrade. While Nextcloud 25 seems quite happy on PHP 7.4, it should be updated given it's out of support now, and we certainly need to do this before upgrading to Nextcloud 26.

Lessons Learned

So this was a little more interesting than I expected. I think there's a lesson here for Nextcloud too to incorporate a disk space check during the setup. - it should be possible to calculate the space needed and to give a warning.

VM snapshots are really useful for maintenance activity.

Make sure your data directory has at least 600 MB remaining before starting an upgrade, probably safer to make that 800 MB to 1 GB. I think I'll expand that disk since I have plans for Test so it'll need more space eventually.