如何升级ownCloud到nextCloud?

Cloud storage

1 理论知识

1.1 升级兼容关系

– ownCloud 9.0.x与Nextcloud 9.0.x兼容
– ownCloud 9.1.x与Nextcloud 10.0.x兼容
– ownCloud 10.0.x与Nextcloud 12.0.x兼容
– ownCloud 10.1至10.5与Nextcloud 20.0.4兼容

2 最佳实践

2.1 升级ownCloud

本章基于ownCloud 10.5.0版本升级到nextCloud 20.0.4,如果你低于此版本,请先按照如下章节升级,

如何升级ownCloud?


基本的环境信息如下,
host name = owncloud.cmdschool.org
ipaddress = 10.168.0.156
OS = CentOS 6.8 x86_64

2.2 准备nextCloud的运行环境

由于两套软件的版本需求不一致,请按照如下章节准备nextCloud的运行环境,

如何部署CentOS 8.x nextCloud?


基本的环境信息如下,
host name = nextcloud.cmdschool.org
ipaddress = 10.168.0.80
OS = CentOS 8.2 x86_64
该服务器只需要一个环境,如果有数据,建议你先使用如下命令清空已经部署的nextCloud代码,

rm -rf /var/www/nextcloud

根据实际的用户文件存放位置,使用类似的命令清空用户数据目录,

rm -rf /data/*

使用如下命令检查是否存在nextCloud的数据库,

mysql -uroot -p
show databases;

如nextCloud的数据库显示如下,

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nextcloud          |
| performance_schema |
+--------------------+
4 rows in set (0.009 sec)

可使用如下命令清理该库,

drop database nextcloud;

2.3 迁移数据至新的环境

2.3.1 标记维护模式

In owncloud,

sudo -u apache php /var/www/owncloud/occ maintenance:mode --on

2.3.2 导出并迁移数据库数据

In owncloud,

mkdir -p /data/backup/
/usr/local/mysql/bin/mysqldump --socket=/var/lib/mysql/mysql.sock -uroot -p owncloud > /data/backup/owncloudBackup.sql

数据库导出到备份目录后,使用如下命令复制数据到另一台服务器,

ssh nextcloud.cmdschool.org mkdir -p /data/backup/
scp /data/backup/owncloudBackup.sql nextcloud.cmdschool.org:/data/backup/

2.3.3 迁移文件数据

In owncloud,

ssh nextcloud.cmdschool.org mkdir -p /data/nextcloud-data/
rsync -avP --delete /data/owncloudData/ nextcloud.cmdschool.org:/data/nextcloud-data/

2.3.4 迁移代码数据

In owncloud,

ssh nextcloud.cmdschool.org mkdir -p /var/www/nextcloud
rsync -avP --delete /var/www/owncloud/ nextcloud.cmdschool.org:/var/www/nextcloud/

由于两台服务器的用户文件数据目录不一致,所以需要使用如下命令修正,

ssh nextcloud.cmdschool.org rm /var/www/nextcloud/data
ssh nextcloud.cmdschool.org ln -s /data/nextcloud-data /var/www/nextcloud/data

2.3.5 导入数据库数据

In nextcloud,

mysql -uroot -p
create database if not exists nextcloud;
grant all privileges on nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloudpwd';
flush privileges;

重新创建数据库后,使用如下命令导入数据,

use nextcloud;
source /data/backup/owncloudBackup.sql;

2.3.6 检查apache是否符合实际需求

cat /etc/httpd/conf.d/nextcloud.conf

配置如下:

<VirtualHost *:80>
  DocumentRoot /var/www/nextcloud/
  ServerName  nextcloud.cmdschool.org

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^nextcloud\.com\.org$
  RewriteRule ^/?(.*)$ https://nextcloud.cmdschool.org/$1 [L,R]
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot /var/www/nextcloud/
  ServerName  nextcloud.cmdschool.org

  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
  SSLCertificateFile /etc/httpd/2_nextcloud.cmdschool.org.crt
  SSLCertificateKeyFile /etc/httpd/3_nextcloud.cmdschool.org.key
  SSLCertificateChainFile /etc/httpd/1_root_bundle.crt

  Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
</VirtualHost>

<Directory /var/www/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off
  </IfModule>
</Directory>

另外,也可以使用如下命令测试,

httpd -t

2.3.8 修正nextlcoud配置

vim /var/www/nextcloud/config/config.php

一般情况下需要修改如下配置,

<?php
$CONFIG = array (
  #...
  'trusted_domains' =>
  array (
    0 => '10.168.0.80',
    1 => 'nextcloud.cmdschool.org',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'http://nextcloud.cmdschool.org',
  'dbtype' => 'mysql',
  'version' => '10.5.0.10',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'nextcloudpwd',
  #...
);

2.3.9 测试迁移后的应用运行

In nextcloud,

sudo -u apache php /var/www/nextcloud/occ maintenance:mode --off

退出运维模式后,可从如下链接使用迁移后的应用,确保正确迁移,
https://nextcloud.cmdschool.org

2.4 升级到nextCloud

2.4.1 准备升级脚本

mv /var/www/nextcloud/updater/index.php /var/www/owncloud/updater/index.php.save
wget https://download.nextcloud.com/server/installer/migrator/index.php -O /var/www/nextcloud/updater/index.php

2.4.2 运行升级向导

https://nextcloud.cmdschool.org/updater/index.php
如果遇到类似的如下提示,

Create backup
Could not copy "/var/www/nextcloud/settings/templates/panels/personal/clients.php.default" to "/var/www/nextcloud/data/updater-occlhagj0wo6/backups/nextcloud-10.168.0.80/settings/templates/panels/personal/clients.php.default"

可使用如下命令解决,

chown apache:apache -R /var/www/nextcloud

如果出现长时间停留于某个步骤,可删除以下文件重新执行,

rm -rf /var/www/nextcloud/data/updater*

2.4.3 根据提示执行升级命令

sudo -u apache php /var/www/nextcloud/occ upgrade

更新如果顺利完成,你可能需要手动启用某些之前升级禁用的应用(以ldap为例),

sudo -u apache php /var/www/nextcloud/occ app:enable user_ldap

最后,可能需要使用如下命令退出维护模式,

sudo -u apache php /var/www/nextcloud/occ maintenance:mode --off

参阅文档
=======================

更新文档
———-
https://docs.nextcloud.com/server/20/admin_manual/maintenance/manual_upgrade.html

安装包下载
——–
https://nextcloud.com/changelog/
https://nextcloud.com/install/

维护文档
————-
https://nextcloud.com/migration/

升级帮助
————–
https://github.com/nextcloud/server/issues/8143
https://help.nextcloud.com/search?q=migration

没有评论

发表评论

Cloud storage
如何监视并自启动nextCloud服务?

1 前言 一个问题,一篇文章,一出故事。 nextCloud在我司属于比较重要的业务,根据以前的经验 …

Cloud storage
如何附加NextCloud的oneDrive存储?

1 基础知识 “files_external_onedrive”插件允许NextCloud扩展微软的 …

Cloud storage
如何解决nextCloud LDAP Operations error?

1 前言 笔者的nextCloud由之前的ownCloud升级而来,过程记录于以下章节, 如何升级o …