Cannot upgrade docker-based nextcloud

I have Nextcloud set up with docker-compose and after a failed upgrade nothing seems to work:

  • with version 20 the container doesn’t start: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (20.0.14.2) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • same with 21: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (21.0.8.3) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • and 22: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (22.2.4.3) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • 23 at least starts but upgrade refuses to run:
$ docker exec zo_nextcloud_1 php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Resetting log level

See also:

$ docker exec zo_nextcloud_1 php occ status
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
  - installed: true
  - version: 23.0.1.2
  - versionstring: 23.0.1
  - edition:
  - maintenance: true
  - needsDbUpgrade: true
  - productname: Nextcloud
  - extendedSupport: false

Any options or did Nextcloud invent a time loop machine?

Which Docker image are you using?

nextcloud:XX-fpm-alpine

the problem is reported often. Downgrade is no supported, so the safe way to return to previous version after upgrade is full recovery of your data and database.

Sometimes removing/editing files like version.php helps

^ this is probably a sign of a fundamental issue that needs to be addressed?

I ended up solving by deleting version.php and trying each of the 5 last versions

may be… or may be users should RTFM:

Update to a newer version

…

It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16.

it’s totally understandable that only some upgrade paths are supported.

But the least I would expect is that if the attempted upgrade is not supported, the upgrade is not attempted and it is possible to roll back to the previous version easily. Currently, you just end up in a state where none of the Docker images will accept to run off the volumes. That’s pretty bad.

Here is a PR to change that: Block upgrade if it is not supported because major versions are too different by wetneb · Pull Request #2018 · nextcloud/docker · GitHub

I am currently stuck with this issue trying to upgrade to 27 from 26 latest-previous-version. There was no versions in-between where I’m coming from and where I’m going to. What should I have done to get this to work?

Updated the images and started the whole thing, now I’m stuck with “Start upgrade”. No error message. Only indication that something might be wrong is the “needsDbUpgrade: true” in occ status.

That’s such an EPIC FAIL.

I just rebuilt all my nextcloud data from scratch. I was stuck on v24 via docker compose with no way to upgrade.