Exception: Updates between multiple major versions and downgrades are unsupported

Nextcloud version (eg, 20.0.5): 20.0.7
Operating system and version (eg, Ubuntu 20.04): Debian 10 Buster (current stable)
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.4): 7.3

The issue you are facing:

Since last night NC has been asking me to upgrade. Once I try to do that, I get:

Exception: Updates between multiple major versions and downgrades are unsupported.

And the server stays in maintenance mode. If I try from the command line, i get slightly more info:

mdione@neomustang:~$ sudo -u www-data php7.3 /var/www/nextcloud/occ upgrade -vvv
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
2021-02-14T08:28:29+00:00 Setting log level to debug
2021-02-14T08:28:29+00:00 Turned on maintenance mode
2021-02-14T08:28:29+00:00 Exception: Updates between multiple major versions and downgrades are unsupported.
2021-02-14T08:28:29+00:00 Update failed
2021-02-14T08:28:29+00:00 Maintenance mode is kept active
2021-02-14T08:28:29+00:00 Resetting log level

And some more info:

mdione@neomustang:~$ sudo -u www-data php7.3 /var/www/nextcloud/occ --version
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
Nextcloud 20.0.7

Is this the first time you’ve seen this error? (Y/N): Y

The output of your Nextcloud log in Admin > Logging: I can’t login right now

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'trusted_domains' =>
  array (
    [...]
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'sqlite3',
  'version' => '17.0.1.1',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

I see the issue here, I’ve been provisioning this file with Ansible. I just tried to replace the version with 20.0.7, and restart apache2, but I still have the same issue. I also wonder how is this different from the version reported above, and why is it even there? I even commented out that line, nothing.

Ah! The version is actually 20.0.7.1! I put the right version in the config file and now all it right.

Why is this not properly reported in the CLI? Should I open a bug for that? Where is it even taking that version? I guess the DB, so why duplicate the info in the config file?

You normally do not touch this at all. After an upgrade the version number in the config file is adjusted. Why didn’t that work for you? Perhaps the updater didn’t finished, the version was overwritten by ansible?

I must had worked, but I run Ansible way later, when I upgraded to PHP 7.3. I even jumped from all the way down from 17.x. and I had no issues, but my session was kept open, so I didn’t had any issues until later. The version was overwritten by Ansible because I used the config file after the first installation as a template. Maybe I shouldn’t do that?

Still, I don’t think this is good practice, putting such data duplicated in a config file. I guess I will open an issue about this.

the updater app creates also a backup of the config-file, so you can check if there were other changes in recent versions. Sometimes they add stuff or some old options are removed.

I don’t see any:

mdione@neomustang:~$ sudo ls /var/www/nextcloud/config/
config.php  config.sample.php

it’s not in the config files, it’s in the data folder, updater-…

Yeah, ok, but the workflow backup file -> template -> config file does not make much sense. And given that evidently the version number is also stored in the db, I still don’t see how it make sense to have it here too.