修复 NextCloud 镜像跨版本升级导致无法打开的问题

昨天升级了 NextCloud 客户端,出现个提示,大概内容就是「服务器版本为16,0,4,1,已不受支持,继续使用后果自负。(大概意思)」之类的,So,那就升级一下咯。

由于所有文件都已经正常备份,所以心态就飘了,升级文档也不好好看了,想着从16直接升级到20,一步到位,轻松 easy。😄

果然,是真的「果然」,意料之中地打不开了,显示什么让你去找管理员,具体报错由于忙着解决问题,忘记截图了。然后仔细去看了升级文档,才发现原来要一个版本一个版本来升,比如我想要从16升到20,必须遵循这个步骤:16->17,17->18,18->19,19->20。每个版本的升级,都会自动更新数据库及插件,跨版本升级会导致前面的操作丢失,无法正常运行。

嗯,问题阐述完了,重点该说说解决办法了,这应该也是大家最关心的地方,谁在乎你的系统是崩了还是炸了,说说怎么解决跨版本升级后的问题才是重点。😁

好的,碰到相同问题的童鞋,可以按一下步骤解决:

(由于我的 NextCloud 是通过容器创建了,此处只说明容器部署方式的处理办法。)

  1. 修改 html/config/config.php 文件的 version 参数,将版本号还原成升级前版本:
'version' => '16,0,4,1',
  1. 修改 html/version.php 文件,还原成升级前的参数:
 
  array (
    '15.0' => true,
    '16.0' => true,
  ),
  'owncloud' => 
  array (
  ),
);
$OC_Build = '2019-08-14T18:57:27+00:00 a1a245e88202d834f08f4c2e4451dcbe9baee3aa';
$vendor = 'nextcloud';

如果升级后忘记了旧版本相关的参数,可以使用旧版本镜像启动一个容器,进入查看相关参数后还原即可。

  1. 下载 17 版本的镜像,重建容器。

在重建容器过程中,查看容器日志,如果看到以下日志,这说明正常升级中:

...
Updating database schema
Updated database
Updating  ...
Updated  to 0.15.1
Checking for update of app accessibility in appstore
Checked for update of app "accessibility" in appstore 
Checking for update of app activity in appstore
Checked for update of app "activity" in appstore 
Checking for update of app announcementcenter in appstore
Checked for update of app "announcementcenter" in appstore 
Checking for update of app apporder in appstore
Checked for update of app "apporder" in appstore 
Checking for update of app bruteforcesettings in appstore
Checked for update of app "bruteforcesettings" in appstore 
Checking for update of app cloud_federation_api in appstore
Checked for update of app "cloud_federation_api" in appstore 
Checking for update of app comments in appstore
Checked for update of app "comments" in appstore 
Checking for update of app dav in appstore
Checked for update of app "dav" in appstore 
Checking for update of app drawio in appstore
Checked for update of app "drawio" in appstore 
Checking for update of app event_update_notification in appstore
Checked for update of app "event_update_notification" in appstore 
Checking for update of app federatedfilesharing in appstore
Checked for update of app "federatedfilesharing" in appstore 
Checking for update of app federation in appstore
Checked for update of app "federation" in appstore 
Checking for update of app files in appstore
Checked for update of app "files" in appstore 
Checking for update of app files_mindmap in appstore
Checked for update of app "files_mindmap" in appstore 
Checking for update of app files_pdfviewer in appstore
Checked for update of app "files_pdfviewer" in appstore 
Checking for update of app files_rightclick in appstore
Checked for update of app "files_rightclick" in appstore 
Checking for update of app files_sharing in appstore
Checked for update of app "files_sharing" in appstore 
Checking for update of app files_trashbin in appstore
Checked for update of app "files_trashbin" in appstore 
Checking for update of app files_versions in appstore
Checked for update of app "files_versions" in appstore 
Checking for update of app files_videoplayer in appstore
Checked for update of app "files_videoplayer" in appstore 
Checking for update of app firstrunwizard in appstore
Checked for update of app "firstrunwizard" in appstore 
Checking for update of app gallery in appstore
Checked for update of app "gallery" in appstore 
...

如果看不到升级日志,只看到访问日志的话,需要手动执行以下命令进行升级:

# 容器名称为 nextcloud-app
# 启动维护模式
docker exec --user www-data nextcloud-app php /var/www/html/occ  maintenance:mode --on

# 使用 occ 升级
docker exec --user www-data nextcloud-app php /var/www/html/occ upgrade

# 关闭维护模式
docker exec --user www-data nextcloud-app php /var/www/html/occ  maintenance:mode --off
  1. 后续的版本升级,就按步骤3,一步一步升级就可以了。

最后的忠告:千万不要贪图方便而跨版本升级,特别是使用容器部署时的跨版本,否则,难免会踩到爬不上来的坑😂。据我所知的,不能跨版本升级的应用有 GitLab 和 NextCloud,估计其他程序也无差。

消息盒子

# 暂无消息 #

只显示最新10条未读和已读信息