Multiple version upgrade failed. How to fix?

Okay, so totally my fault, did not read docs beforehand to find that multiple version upgrade is not supported.

Had 15.0.2 installed; and tried to upgrade to 17.

fpm_1  | Initializing nextcloud ...
fpm_1  | Upgrading nextcloud from ...
fpm_1  | Initializing finished
fpm_1  | Nextcloud or one of the apps require upgrade - only a limited number of commands are available
fpm_1  | You may use your browser or the occ upgrade command to do the upgrade
fpm_1  | Set log level to debug
fpm_1  | Turned on maintenance mode
fpm_1  | Exception: Updates between multiple major versions and downgrades are unsupported.
fpm_1  | Update failed
fpm_1  | Maintenance mode is kept active

Then tried to set it to v16, but that fails to start:

fpm_1  | Can't start Nextcloud because the version of the data ( is higher than the docker image version ( and downgrading is not supported. Are you sure you have pulled the newest image version?

Same issue happens if I try to go back to previous version that was used (15). Config file lists version 15 as the current one.

What steps should I take to take care of this issue?

just a quick question: you don’t have any backups that you could restore?

Stored data seems to be present (on hdd), and I only have backups of that.

I don’t have any additional backups for Nextcloud configuration; only daily database dumps which would be shame to restore into (not even sure if that version got saved into DB?)

I have found a file called version.php, maybe changing version back to 15 there would help? Don’t want to experiment and mess things even more

Edit: seems that setting version.php to previous version, bumping container to +1 version and then running upgrade/migrations/turning off maintenance is enough to get things working again.