0

I am running my private Nextcloud instance using docker (docker-compose). I tried to upgrade to a newer Nextcloud version but did not realize I was not supposed to skip a major version (from 21 to 23). Now I cant start it at all:

  • When I try to start the container with version 23 and trigger the upgrade, it fails because it cannot upgrade from 21:
    leifb@***:~/nextcloud$ sudo docker-compose exec --user www-data app php occ upgrade
    Nextcloud or one of the apps require upgrade - only a limited number of commands are available
    [...]
    Exception: Updates between multiple major versions and downgrades are unsupported.
    Update failed
    [...]
    
  • When I try to start the container with version <23, it fails because it thinks the data is from version 23:
    app_1  | Can't start Nextcloud because the version of the data (23.0.3.2) is higher than the docker image version (22.2.6.2) and downgrading is not supported. Are you sure you have pulled the newest image version?
    

Is there a way to force a upgrade or starting with version 22?

Here is my docker-compose file:

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=***
      - MYSQL_PASSWORD=***
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud:22
    restart: always
    ports:
      - 9009:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=***
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - OVERWRITEHOST=***
      - OVERWRITEPROTOCOL=https

Thank you!

Leifb
  • 75
  • 8

1 Answers1

0

I was able to fix the problem by manually changing the version in the version.php file of the nextcloud volume.

This might cause irreparable problems, back up your data if you want to do the same!

The complete path for that file was: /var/lib/docker/volumes/nextcloud_nextcloud/_data/version.php

I had an old nextcloud volume lying around which I created when I initially set up nextcloud. I just used the version.php from that volume, as I was quite confident that it had the correct version.

Here is what changed:

"incorrect" version.php:

<?php 
$OC_Version = array(23,0,3,2);
$OC_VersionString = '23.0.3';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' => 
  array (
    '22.2' => true,
    '23.0' => true,
  ),
  'owncloud' => 
  array (
    '10.5' => true,
  ),
);
$OC_Build = '2022-03-21T13:05:48+00:00 5f6449283b5eb3cd0c96f475ff6f68a6c73a8140';
$vendor = 'nextcloud';

"correct" version.php:

<?php 
$OC_Version = array(21,0,1,1);
$OC_VersionString = '21.0.1';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' => 
  array (
    '20.0' => true,
    '21.0' => true,
  ),
  'owncloud' => 
  array (
    '10.5' => true,
  ),
);
$OC_Build = '2021-04-08T13:32:52+00:00 bd555dbe8568b2509bd7d82fabbe38d76c86afbe'
;
$vendor = 'nextcloud';

After that change, I could start nextcloud in version 21 first, to check whether everything was still there. Next I was able start and update to 22 and 23 in steps just fine.

PS:

docker-compose exec --user www-data app php occ Allows you to manually update and disable maintenance mode.

Leifb
  • 75
  • 8