Upgrading Nextcloud

Nextcloud version (eg, 20.0.5): 21.0.2.1 → 24.0.6.1
Operating system and version (eg, Ubuntu 20.04): Docker 17.06.0-dev (linux/arm)
Apache or nginx version (eg, Apache 2.4.25): nextcloud:latest
TNAS

I think I’ve got myself into a proper mess.

My docker images on my TNAS were running very slowly, so as part of the process to look into this I upgraded my images to the latest.

The mairadb seemed to upgrade OK, although I can’t be 100% certain but the docker-compose exec -it mariadb-upgrade reported that there was nothing to upgrade.

Starting the nextcloud container and logging onto the local machine I get the message that nextcloud in in maintenance mode.

A bit of Googling and I edit the config.php to mark that it’s not in maintenance mode and restart and I get a list of things to be updated.

Pressing the ‘Update’ button I get an error a few seconds late telling me about a CSRF warning - So I try connecting to the container using docker exec -it -u33 container and execute a ./occ upgrade only to get the warning : Exception: Updates between multiple major versions and downgrades are unsupported.

Soooo I downgrade my container image back to 20.0 and try and restart nextcloud. It failed - Checking the logs I see: Can't start Nextcloud because the version of the data (24.0.6.1) is higher than the docker image version (21.0.9.1)

Is there anyway out of this mess I’ve made for myself?

Hi @Milner_Household welcome to the community.

Please never try to upgrade more than one version at time, perform proper backup before doing so and don’t try to upgrade the system inside of the container (neither occ nor webupdater).

please find the right Docker upgrade procedure here:

recovering from the problem when you failed unsupported upgrade could be tricky but was discussed often in this forum, please use search function: https://help.nextcloud.com/search?q="Can't%20start%20Nextcloud%20because%20the%20version%20of%20the%20data"%20"is%20higher%20than%20the%20docker%20image%20version"

maybe this is a good starting point:

1 Like

You don’t say… I would heed that warning if I were you.

Restoring from the backup you took before the upgrade is probably the safest course. Barring that, you’ll need to run the version that matches what your database has upgraded to. You can find those tags on https://hub.docker.com.

Looks like you need version 24.

The pointer to the “Can’t start nextcloud because the version of the data is higher…” pointed me in the correct direction - Many many thanks.

1 Like

Lessons learned

  • Don’t do an upgrade on a whim - Plan it!
  • Backup stuff first.

Finally sorted the mess out - I copied the data and config directories from persistent docker volume and left the database in place.

I then removed the volume, pulled the latest nextcloud (24.0.6.1) and started it. After it started I stopped it and then placed the data and config directories back into the newly created persistent volume and restarted.

After that I ran docker-compose exec --user www-data app php occ upgrade and left it do it’s stuff for a bit.

app being the name of the section in the docker-compose.yml file for nextcloud

After that I regained access to a working nextcloud setup.

<Phew!>

It’s great you managed to sort out the issue! :fireworks:

from your description I understand you didn’t perform upgrade steps 21 > 22 > 23 > 24 but “somehow” tricked NC24 to use the 21 data set. depending on your data and applications this could result in issues (later). As KarlF12 stated most likely the best practice is to start with a known good backup of your 21.0.9.1 and perform all the upgrades in a proper way (you can do one after another… it only takes longer as usual)

Any backup would have been helpful, but that wasn’t something I had.

Planning backups is on my todo list now.

The power of using LXC and ZFS is in fact automation of snapshots. I can strongly recommend it. Has been running rock solid for a couple of years now, and I have needed to rollback to previous snapshots a couple of times, because I have also automated upgrades of NC.