前言
基于《Docker系列 搭建个人云盘服务nextcloud》,相信无论是在有/无443端口的Linux机子里均可成功安装Nextcloud,也摘录了各种安装Nextcloud中可能出现的警告/Bug的解决方案。值得一提的是,Nextcloud是一个被频繁维护和更新的应用,而且Nextcloud官方也在积极维护着自己的镜像。一般而言,开发者是为修复bug、增加特性、提升安全性、提升性能等目的才会更新应用的;因此,在绝大多数情况下,成功升级Nextcloud基本上都是好处。
对于普通的docker应用,可以用下面的策略进行升级:
- 通过
docker-compose down
下线Stack - 删除应用对应的image
- 通过
docker-compose up -d
上线并拉取最新镜像(此时应该在docker-compose.yml里指定image版本号或latest
)
然而,Nextcloud不太可能通过该方法成功升级。此外,如果你是通过Docker安装Nextcloud,通过内置的升级通道也是不太可能成功的:
那么,我们是否应该升级Nextcloud?什么时候是最好的时机?本文结合我的一次跨版本Nextcloud升级和踩坑经验,讨论并总结一下如何升级Docker版Nextcloud。你也可以到文章底部的“升级记录”了解我每次升级的过程。
是否升级?
这里我列举一些最近跨版本升级的代价:
- Nextcloud的封面重置为默认状态(下图是我重新换了一张):
- 某些插件不可用,比如onlyoffice等。
所有的数据都没有丢失,包括与联系人信息相关的CalDav应用。此外,个人觉得新版本的Nextcloud性能有所提升——可能是因为Nextcloud(25.x)使用了php8的原因;或者有其它我未曾了解的原因。
总的来说,这次大升级可谓有惊无险,收获满满。如果你Linux基础比较好,并且备份做好,建议在通读本文后一试。小白折腾要慎重 ヾ(≧∇≦*)ゝ
跨版本升级
这次我的升级过程是跨版本升级:23.0.0.10→25.0.2
。但是,如果你直接这样做,你会遇到一个不支持跨版本升级的Error,它通常包括但不限于下面的提示:
Exception: Updates between multiple major versions and downgrades are unsupported
因此,Nextcloud升级的过程是循序渐进的,即:先升级至相邻版本,然后逐步更新至latest版本。
那么如何确定中间版本呢?有三个技巧可以参考:
- Nextcloud changlog,上面会列举每次升级的细节,包括版本号:
- Nextcloud Dockerhub,上面往往会有大版本的最后/最新版本号:
- 版本号法。比如,23可以直升24,24可以直升25;但23不可以直升25。
我升级的版本路线为:23.0.0.10→23.0.12→24.0.8→25.0.2
,基本上是按上面的原则来确定版本号的,大家可参考。
关键数据
我在nextcloud的docker-compose.yml所在目录里运行:
tree -ha -L 2
可以看到下列文件结构:
通常来说,app
、cache
、db
在duplicati里都是同时备份的。但你要特别注意app
中的config
和data
文件夹,它们两个包含最重要的核心数据(配置、文件)。你在升级时,甚至可以只保留config
和data
文件夹;升级完成后Nextcloud的文件和配置也不会丢失。
一般步骤
- 做好备份,比如基于duplicati。
docker-compose down
下线应用。- 修改docker-compose.yml,将nextcloud镜像的版本号改成待升级的版本号:
docker-compose up -d
,静待镜像拉取完成。- 通过
docker logs -f nextcloud-app-1
之类的命令监测升级log
。 - 为节省磁盘空间,可以删除Nextcloud旧镜像。整个stack还包括redis和mariadb,它们的镜像维持原样即可。
升级报错
这里展示了一个比较完整的升级log
:
一般地,这里的速度是很慢的:
Initializing nextcloud <新版本号>...
Upgrading nextcloud from <旧版本号> ...
并且,每次更新的log都可能不太一样的。不一定会有successfull
字样,但一般不会有error
字样。
如果我们看到AH00094: Command line: 'apache2 -D FOREGROUND'
之类的日志,表明Nextcloud已经准备就绪了,你可以访问一下网站看看有什么提示。一般地,它还会让你确认一下更新,你就确认即可。
中途可能有其它错误,但这些错误一般不太可能涉及数据库;这种情况下基本没关系,可以重启页面试试。这里展示一个在网页升级的日志(不记得是哪一次升级了):
正在准备更新
设置日志级别为 调试
启用维护模式
修复日志 步骤: Repair MySQL collation
修复 信息: All tables already have the correct collation -> nothing to do
修复日志 步骤: Repair SQLite autoincrement
修复日志 步骤: Copy data from accounts table when migrating from ownCloud
修复日志 步骤: Drop account terms table when migrating from ownCloud
正在更新数据库结构
数据库已更新
修复日志 步骤: Repair MySQL collation
修复 信息: All tables already have the correct collation -> nothing to do
修复日志 步骤: Repair mime types
修复日志 步骤: Clean tags and favorites
修复 信息: 0 tags of deleted users have been removed.
修复 信息: 0 tags for delete files have been removed.
修复 信息: 0 tag entries for deleted tags have been removed.
修复 信息: 0 tags with no entries have been removed.
修复日志 步骤: Repair invalid shares
修复日志 步骤: Move .step file of updater to backup location
修复日志 步骤: Add move avatar background job
修复 信息: Repair step already executed
修复日志 步骤: Add preview cleanup background jobs
修复日志 步骤: Migrate oauth2_clients table to nextcloud schema
修复 信息: Update the oauth2_access_tokens table schema.
修复 信息: Update the oauth2_clients table schema.
修复日志 步骤: Fix potential broken mount points
修复 信息: No mounts updated
修复日志 步骤: Repair language codes
修复日志 步骤: Install new core bundle components
修复日志 步骤: Add log rotate job
修复日志 步骤: Clear frontend caches
修复 信息: Image cache cleared
修复 信息: SCSS cache cleared
修复 信息: JS cache cleared
修复日志 步骤: Clear every generated avatar on major updates
修复日志 步骤: Add preview background cleanup job
修复日志 步骤: Queue a one-time job to cleanup old backups of the updater
修复日志 步骤: Cleanup invalid photocache files for carddav
修复日志 步骤: Add background job to cleanup login flow v2 tokens
修复日志 步骤: Remove potentially over exposing share links
修复 信息: No need to remove link shares.
修复日志 步骤: Clear access cache of projects
修复日志 步骤: Reset generated avatar flag
修复日志 步骤: Keep legacy encryption enabled
修复日志 步骤: Check encryption key format
修复日志 步骤: Remove old dashboard app config data
修复日志 步骤: Add job to cleanup the bruteforce entries
修复日志 步骤: Queue a one-time job to check for user uploaded certificates
修复日志 步骤: Repair DAV shares
修复日志 步骤: Add background job to set the lookup server share state for users
开始代码完整性检查
发生错误。
必要情况下,可以docker-compose restart
重启该stack,甚至是重启整个VPS/NAS。我当时升级为25x版本时,可能NAS配置太差,一直卡着不动,我直接强行关机再启动NAS,后来一切如常。
整个过程可能会不太顺利。不要怕,只要data
和config
的数据不丢失,就可以苟住!
维护模式
升级Nextcloud的过程中,维护模式是很常见的。它通常有类似提示:
Nextcloud is in maintenance mode
有时候维护模式并不一定代表Nextcloud完全不能运行。你可以尝试关闭维护模式,自己调试一下网站,看是否可以正常登陆。你可以这样做:
- 方法1:进入Nextcloud的根目录,打开
/config/config.php
,将maintenance的值改为false后重启stack:
- 方法2:通过容器php关闭维护模式:
# 进入Nextcloud内部
docker exec -it -u www-data nextcloud-app-1 /bin/bash
# 关闭维护模式
php occ maintenance:mode --off
首选第1种方法,如果不行再试第2种。一般都可以成功关闭。
Nextcloud 25概览
更多Nextcloud Hub 3升级特性可见:Nextcloud Mail improvements
我2022-12-18升级的是的最新版Nextcloud镜像。大致如下:
- 主页
- 文件
- 图片:
- PicGo:我用PicGo上传了一下图片,功能不受影响。Nextcloud图床的相关教程见《Docker系列 深度使用nextcloud(三)Typora图床》。
- 管理后台:
UI重新设置了一下,感觉和23版本差别较小。
小结
如果你只是更新一个相邻的版本,其实也挺快的。如果你一直不更新Nextcloud,短期内问题也不大;但是从长期看,由于跨版本升级的不兼容性,更新越少越难;不更新就无法享受一些新特性(但对大多数人来说可能也没什么损失)。我开始时是在NAS里更新一个比较旧的Nextcloud版本,踩坑较多;但在VPS里较新版本里更新就较顺利。
对Nextcloud的家庭用户,我建议每半年或每年找一个空闲的时间更新一下Nextcloud。只要做好备份,基本上是稳的,绝大多数重要配置均不会丢失。建议技术较好、内心较强的小伙伴去折腾一下!
根目录.htaccess
的配置内容可能在更新时会丢失,做好备份即可。
如果升级完成后,管理——概览——安全与设置警告
并不能完全通过检测,请至《Docker系列 搭建个人云盘服务nextcloud》的警告&Bug
小节寻找解决方案。
有什么问题,请评论区留言喔!
扩展阅读
- https://nextcloud.com/changelog:如果跨版本升级,需要根据这个nextcloud changelog一步步升级。
- https://hub.docker.com/_/nextcloud:官方Docker镜像
- Update to 13 – “Nextcloud is in maintenance mode” – ℹ️ Support – Nextcloud community
- HSTS on docker container? – ℹ️ Support / 📦 Appliances (Docker, Snappy, VM, NCP, AIO) – Nextcloud community
- The “Strict-Transport-Security” HTTP header is not set to at least “15552000” seconds. For enhanced security, it is recommended to enable HSTS – ℹ️ Support – Nextcloud community
- Updates between multiple major versions are unsupported – 📑 How to – Nextcloud community
升级记录
记录我的Nextcloud升级记录。访客可忽略。
2024-04-27
28.0.3.2 → 29.0.0.19。暂时感觉v29不太稳定,暂不建议升级。
升级日志:
Configuring Redis as session handler
Initializing nextcloud 29.0.0.19 ...
Upgrading nextcloud from 28.0.3.2 ...
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/pre-upgrade
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
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: calendar
Disabled incompatible app: files_accesscontrol
Disabled incompatible app: tasks
Disabled incompatible app: theming_customcss
Updating <federation> ...
Updated <federation> to 1.19.0
Updating <lookup_server_connector> ...
Updated <lookup_server_connector> to 1.17.0
Updating <oauth2> ...
Updated <oauth2> to 1.17.0
Updating <password_policy> ...
Updated <password_policy> to 1.19.0
Updating <photos> ...
Updated <photos> to 2.5.0
Updating <files> ...
Updated <files> to 2.1.0
Updating <activity> ...
Updated <activity> to 2.21.1
Updating <circles> ...
Updated <circles> to 29.0.0-dev
Updating <cloud_federation_api> ...
Updated <cloud_federation_api> to 1.12.0
Updating <dav> ...
Fix broken values of calendar objects
Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [>---------------------------] 0% Starting ...
Updated <dav> to 1.30.1
Updating <files_external> ...
Updated <files_external> to 1.21.0
Updating <files_sharing> ...
Fix broken values of calendar objects
0/0 [->--------------------------] 0% Starting ...
0/0 [--->------------------------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
Updated <files_sharing> to 1.21.0
Updating <files_trashbin> ...
Updated <files_trashbin> to 1.19.0
Updating <files_versions> ...
Updated <files_versions> to 1.22.0
Updating <sharebymail> ...
Updated <sharebymail> to 1.19.0
Updating <workflowengine> ...
Fix broken values of calendar objects
0/0 [----->----------------------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [------->--------------------] 0% Starting ...
Updated <workflowengine> to 2.11.0
Updating <admin_audit> ...
Updated <admin_audit> to 1.19.0
Updating <comments> ...
Updated <comments> to 1.19.0
Updating <firstrunwizard> ...
Updated <firstrunwizard> to 2.18.0
Updating <logreader> ...
Updated <logreader> to 2.14.0
Updating <nextcloud_announcements> ...
Updated <nextcloud_announcements> to 1.18.0
Updating <notifications> ...
Updated <notifications> to 2.17.0
Updating <systemtags> ...
Updated <systemtags> to 1.19.0
Updating <theming> ...
Fix broken values of calendar objects
0/0 [--------->------------------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [----------->----------------] 0% Starting ...
Updated <theming> to 2.4.0
Updating <contactsinteraction> ...
Updated <contactsinteraction> to 1.10.0
Updating <dashboard> ...
Updated <dashboard> to 7.9.0
Updating <federatedfilesharing> ...
Updated <federatedfilesharing> to 1.19.0
Updating <files_pdfviewer> ...
Updated <files_pdfviewer> to 2.10.0
Updating <files_reminders> ...
Updated <files_reminders> to 1.2.0
Updating <privacy> ...
Updated <privacy> to 1.13.0
Updating <provisioning_api> ...
Updated <provisioning_api> to 1.19.0
Updating <recommendations> ...
Updated <recommendations> to 2.1.0
Updating <related_resources> ...
Updated <related_resources> to 1.4.0
Updating <serverinfo> ...
Updated <serverinfo> to 1.19.0
Updating <settings> ...
Updated <settings> to 1.12.0
Updating <support> ...
Fix broken values of calendar objects
0/0 [------------->--------------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [-------------->-------------] 0% Starting ...
Updated <support> to 1.12.0
Updating <survey_client> ...
Fix broken values of calendar objects
0/0 [---------------->-----------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [------------------>---------] 0% Starting ...
Updated <survey_client> to 1.17.0
Updating <text> ...
Fix broken values of calendar objects
0/0 [-------------------->-------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [---------------------->-----] 0% Starting ...
Updated <text> to 3.10.0
Updating <twofactor_backupcodes> ...
Fix broken values of calendar objects
0/0 [------------------------>---] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [-------------------------->-] 0% Starting ...
Updated <twofactor_backupcodes> to 1.18.0
Updating <updatenotification> ...
Updated <updatenotification> to 1.19.1
Updating <user_status> ...
Updated <user_status> to 1.9.0
Updating <viewer> ...
Updated <viewer> to 2.3.0
Updating <weather_status> ...
Updated <weather_status> to 1.9.0
Update app contacts from App Store
Update app calendar from App Store
Update app documentserver_community from App Store
Fix broken values of calendar objects
0/0 [>---------------------------] 0% Starting ...
Clean up old calendar subscriptions from deleted users that were not cleaned-up
0/0 [->--------------------------] 0% Starting ...
Repair warning: Error while trying to rebuild fonts, if you had any custom fonts configured you'll need to run `occ documentserver:fonts --rebuild`
Update app files_accesscontrol from App Store
Update app onlyoffice from App Store
Update app theming_customcss from App Store
Starting code integrity check...
Finished code integrity check
Update successful
Turned off maintenance mode
Resetting log level
The following apps have been disabled:
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/post-upgrade
Initializing finished
nginx设置要调整:https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/insecure/mariadb/fpm/web/nginx.conf
2024-03-09
28.0.2.5 to 28.0.3.2
-
半透明调整详见《Docker系列 深度使用nextcloud (十一) 特效》。
-
user.ini
重置,可以参考《Docker系列 搭建nextcloud-fpm + nginx网络服务器》优化。
毕竟是小版本更新,整体上比较顺利,升级日志没啥特别:
Configuring Redis as session handler
Initializing nextcloud 28.0.3.2 ...
Upgrading nextcloud from 28.0.2.5 ...
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/pre-upgrade
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
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: sharingpath
Update app calendar from App Store
Update app contacts from App Store
Starting code integrity check...
Finished code integrity check
Update successful
Turned off maintenance mode
Resetting log level
The following apps have been disabled:
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/post-upgrade
Initializing finished
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/before-starting
2024-03-09 11:13:26,052 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
crond: crond (busybox 1.35.0) started, log level 8
[09-Mar-2024 11:13:27] NOTICE: fpm is running, pid 91
[09-Mar-2024 11:13:27] NOTICE: ready to handle connections
2024-02-09
基于《Docker系列 搭建nextcloud-fpm + nginx网络服务器》,从27.1.3升级至28.0.2。新版本在图标等方面与旧版略有不同;而且增加了AI相关支持,但我暂时了解不多。除此之外,新版本28.0.2有很多设置与前版本不一样。具体如下:
额外CSS
需要从新添加一个额外CSS以保证文件/分享页面的半透明化,具体见《Docker系列 深度使用nextcloud (十一) 特效》的“特效——其它半透明”小节。
Onlyoffice需重新上线
这是个老问题。相关bug详见《Docker系列 深度使用nextcloud(四)onlyoffice》。
Activity(动态)加载异常
之前没见过。根据“Activity and Logging sections in admin’s setting shows blank pages – ℹ️ Support – Nextcloud community”所述,与该安全与设置警告Could not check for JavaScript support. Please check manually if your webserver serves .mjs files using the JavaScript MIME type.
相关。方法如下:
我们在nextcloud的docker安装根目录下线整个stack:
docker-compose down
然后,运行文件查看命令:
tree -L 2 -tD
结果类似:
.
├── [ 33 Feb 9 12:43] app
│ ├── [ 50 Feb 9 12:43] 3rdparty
│ ├── [ 50 Feb 9 12:43] apps
│ ├── ...
│ └── [ 403 Feb 9 12:43] version.php
├── [ 3 Feb 9 18:05] cache
│ └── [608K Feb 9 18:05] dump.rdb
├── [ 3 Nov 26 10:09] custom
│ └── [ 22K Jun 8 2023] www.conf
├── [ 20 Feb 9 17:44] db
│ ├── [416K Feb 9 17:53] aria_log.00000001
│ ├── ...
│ └── [ 106 Jun 7 2023] sys
├── [ 78 Jun 7 2023] db.env
├── [1.7K Nov 23 22:44] docker-compose.yml
└── [ 4 Feb 9 18:04] web
├── [ 88 Oct 12 21:26] Dockerfile
└── [7.6K Feb 9 18:02] nginx.conf
xx directories, xx files
其中,这个web/nginx.conf
里要新增一小段文字:
types {
application/javascript js mjs;
}
具体位置如下:
然后删除旧的nginx镜像:
# docker rmi nextcloud4-fpm_web
docker rmi nextcloud-fpm_web
重新上线整个stack,这个过程会自动build新的nextcloud-fpm_web
镜像,从而让新nginx.conf
生效:
docker-compose up -d
最后,重新登陆nextcloud以加载新的js设置即可生效。
设置维护开始时间
Server has no maintenance window start time configured. This means resource intensive daily background jobs will also be executed during your main usage time. We recommend to set it to a time of low usage, so users are less impacted by the load caused from these heavy tasks.
也是28.x.x
刚开始出现的设置;在config/config.php
中添加这一项即可:
'maintenance_window_start' => 1,
维护开始的时间包括用于活动过期、可疑登录训练和更新检查。例如,设置'maintenance_window_start' => 1,
,则只会在 UTC 时间凌晨 01:00 到 05:00 之间运行后台作业。
无法上传大文件
根据《Docker系列 搭建个人云盘服务nextcloud-apache》中无法上传>512M的文件
处理。
2023-03-25
PVE.OMV.Nextcloud3; 25.0.3-26.0.0。升级更高版本
最好先禁用Onlyoffice和Community Document Server再进行升级。升级后需要在.htaccess里增加启用HSTS的代码。要重装ffmepg。升级完成后记得重启Onlyoffice和Community Document Server。
2022-02-04
PVE.OMV.Nextcloud3; 25.0.2-25.0.3
最好先禁用onlyoffice和Community Document Server再进行升级。升级后需要在.htaccess里增加启用HSTS的代码。要重装ffmepg。整个过程挺顺利的,log如下:
Initializing nextcloud 25.0.3.2 ...
Upgrading nextcloud from 25.0.2.3 ...
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
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: documentserver_community
Disabled incompatible app: onlyoffice
Starting code integrity check...
Finished code integrity check
Update successful
Turned off maintenance mode
Resetting log level
The following apps have been disabled:
Initializing finished
---------------
完结,撒花!如果您点一下广告,可以养活苯苯😍😍😍
从28.0.1升级到28.0.2,按照“Activity(动态)加载异常”的解决方法操作了一下,始终不生效…对网站运行有什么影响吗
对我来说有影响,因为我会经常看这个页面 (~ ̄▽ ̄)~ 你不怎么看就没影响喽 ~ 你是按我的教程来安装的nextcloud吗?
这个页面我还没看到过,对我这边影响不大。我是按照“Docker系列 搭建nextcloud-fpm + nginx网络服务器”这个教程安装的nextcloud,这个教程很赞ヾ(≧∇≦*)ゝ
😀感谢感谢