大网数据广告活动
服务器运维问答

How to fix a Nextcloud docker container after skipping a major version?

· 52CE 我爱测

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:…

问题原文

原帖链接 · Leifb · CC BY-SA 4.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 · CC BY-SA 4.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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-04-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。