Skipped major version 21->23, did not run the updater yet

Nextcloud version (eg, 20.0.5): 21.0.4
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): 2.4
PHP version (eg, 7.4): 7.4.24

The issue you are facing:
Cannot start Nextcloud.

  • When launching version 23, it is in maintenance mode and turning the maintenance mode off offers the web updater (didn’t run it as I am worried the update procedure will surely fail).
  • When launching version 21, it fails to start with error saying that data version is already 23.

As I understand the issue, somehow some part of update was run (hopefully only some tag in DB) despite not launching the update itself.

I see two solutions, either try to revert the change (this I tried but failed to find any mention of the version 23…), or YOLO run the update and pray.
(Third is to burn everything and install 23 fresh which I’d love to avoid.)

Any ideas how to proceed from here are very welcome.

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

Steps to replicate it:

  1. Run docker NC 21.0.4 and have it working normally
  2. Stop the container
  3. Run docker NC 23.0.5 (current production tag)
  4. Access your NC via browser to see maintenance mode
  5. Turn off maintenance mode
  6. Access your NC via browser to see updater… and realize the mistake

The output of your Nextcloud 21:

nextcloud-app | Can't start Nextcloud because the version of the data (23.0.5.1) is higher than the docker image version (21.0.4.1) and downgrading is not supported. Are you sure you have pulled the newest image version?
nextcloud-app exited with code 1

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => '...',
  'passwordsalt' => '...',
  'secret' => '...',
  'trusted_domains' => 
  array (
    0 => '...',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '21.0.4.1',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '...',
  'installed' => true,
  'maintenance' => true,
  'theme' => '',
  'loglevel' => 0,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_domain' => '...',
  'mail_smtphost' => '...',
  'mail_smtpport' => '465',
  'mail_smtptimeout' => 10,
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '...',
  'mail_smtppassword' => '...',
  'overwrite.cli.url' => 'https://...',
  'updater.release.channel' => 'stable',
);

Okay, after much pain I figured out what was wrong so let me share it in case it will be useful to somebody else.

There is a file version.php mentioned in some answers to similar questions. That file is indeed the key but it is inside the container on the named volume (if you followed the default option mentioned on Github for NC Docker) and your broken NC image (in my case version 21) keeps restarting (shutting down) due to the version mismatch and thus prevents you from connecting to it and changing the file the easy way.

  1. So I had to stop the NC container and create another container that connected to the named volume.
    (I used blank ubuntu image which was not ideal as I had no text editor but worked well enough for rough test. Use what is best for your Docker installation.)

  2. Then I checked the file /var/www/html/version.php and there was the bad data version (23 in my case). Since I didn’t have a backup, I crafted a new file as follows:

version.php for v23

<?php 
$OC_Version = array(23,0,5,1);
$OC_VersionString = '23.0.5';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' => 
  array (
    '22.2' => true,
    '23.0' => true,
  ),
  'owncloud' => 
  array (
    '10.5' => true,
  ),
);
$OC_Build = '2022-05-19T11:53:28+00:00 e86a773f6e144b07dca4685d905ab1caa5e6d439';
$vendor = 'nextcloud';

my handcrafted version.php for v21

<?php 
$OC_Version = array(21,0,4,1);
$OC_VersionString = '21.0.4';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' => 
  array (
    '21.0' => true,
  ),
  'owncloud' => 
  array (
    '10.5' => true,
  ),
);
$OC_Build = '';
$vendor = 'nextcloud';
  1. Then I ran NC container with my version 21.0.4 which finally started. However, I was met with a version mismatch error on every app and the NC instance was unusable.
    (Possibly due to me leaving the OC_Build variable empty, others have reported success in this step already when recovering this file from backup.)

  2. Next step was to stop it again and pull a legit update for my version, e.g. 21.0.9. This triggered the update process correctly and after updating a few apps, it launched happily. NC is back on!

  3. I continued with iterative updates and now I am running NC 23 - success! A few things to note:

    • I never ran the update but based on what other people said and the app version mismatch error I got, there should be no difference. The damage is done, hard to recover (mostly because there is no official information) but possible.
    • Every update warned me that it disabled many of my apps but when I signed in, they were all enabled as I had them before.