I ran into an error while attempting to migrate from Owncloud 10.1.0 to Nextcloud. I had read that the proper migration path for Owncloud 10.0.x was to migrate to Nextcloud 12.0.x, so I downloaded Nextcloud 12.0.13. Since I have backups of my data, configuration and database I attempted the migration.
I followed the manual migration instructions at: https://docs.nextcloud.com/server/15/admin_manual/maintenance/manual_upgrade.html
To start the upgrade process I first edited version.php to allow upgrading from Owncloud 10.1.0.
When I ran the upgrade command:
sudo -u www-data php occ upgrade
the upgrade fails because of this exception:
An exception occurred while executing 'DROP TABLE oc_accounts':
1217 Cannot delete or update a parent row: a foreign key constraint fails
To solve this, I needed to remove the foreign key constraints.
To find all foreign keys of the oc_accounts table, I ran this query in the mysql terminal:
select
table_name,column_name,constraint_name,referenced_table_name,referenced_column_name
from
information_schema.key_column_usage
where
referenced_table_schema = 'frontier_cloud' and
referenced_table_name = 'oc_accounts';
The output was:
+---------------------+------------------+---------------------+-----------------------+------------------------+
| table_name | column_name | constraint_name | referenced_table_name | referenced_column_name |
+---------------------+------------------+---------------------+-----------------------+------------------------+
| oc_persistent_locks | owner_account_id | FK_F0C3D55BC901C6FF | oc_accounts | id |
+---------------------+------------------+---------------------+-----------------------+------------------------+
Next, I looked at the oc_persistent_locks table by doing:
show create table oc_persistent_locks
In this table there were two constraints. The first was:
CONSTRAINT `FK_F0C3D55BC901C6FF` FOREIGN KEY (`owner_account_id`) REFERENCES `oc_accounts` (`id`) ON DELETE CASCADE
To remove the constraint and key I used the following:
alter table oc_persistent_locks
drop foreign key FK_F0C3D55BC901C6FF,
drop owner_account_id;
I used the same method to remove the second constraint and key (oc_filecache). It seems this same error was detailed in this issue, which helped point me in the right direction.
After this I was able to complete the upgrade process successfully.
Operating system: Ubuntu 18.04.2
Web server: Apache2
Database: MySQL
PHP version: 7.1.26
Nextcloud version: 12.0.13
Updated from an older Nextcloud/ownCloud or fresh install: Updated from Owncloud 10.1.0
Where did you install Nextcloud from: Archive
Signing status:
Results
=======
- core
- INVALID_HASH
- version.php
_I had to edit version.php to add owncloud 10.1.0 to the supported versions_
List of activated apps:
App list
Enabled:
- bruteforcesettings: 1.3.0
- comments: 1.2.0
- dav: 1.3.1
- federatedfilesharing: 1.2.0
- federation: 1.2.0
- files: 1.7.2
- files_external: 1.3.0
- files_trashbin: 1.2.0
- files_versions: 1.5.0
- files_videoplayer: 1.1.0
- firstrunwizard: 2.1
- logreader: 2.0.0
- lookup_server_connector: 1.0.0
- nextcloud_announcements: 1.1
- notifications: 2.0.0
- oauth2: 1.0.6
- password_policy: 1.2.2
- provisioning_api: 1.2.0
- serverinfo: 1.2.0
- sharebymail: 1.2.0
- survey_client: 1.0.0
- systemtags: 1.2.0
- theming: 1.3.0
- twofactor_backupcodes: 1.1.1
- updatenotification: 1.2.0
- workflowengine: 1.2.0
Disabled:
- activity
- admin_audit
- encryption
- files_pdfviewer
- files_sharing
- files_texteditor
- gallery
- user_external
- user_ldap
Nextcloud configuration:
Config report
{
"system": {
"instanceid": "oc6ehmsu4frn",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"192.168.1.50",
"fsi.us.to"
],
"datadirectory": "\/data\/cloud\/",
"overwrite.cli.url": "http:\/\/fsi.us.to\/nextcloud",
"dbtype": "mysql",
"version": "12.0.13.2",
"dbname": "frontier_cloud",
"dbhost": "localhost",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"logtimezone": "UTC",
"installed": true,
"loglevel": 2,
"maintenance": false,
"updater.secret": "***REMOVED SENSITIVE VALUE***"
}
}
Are you using external storage, if yes which one: No
Are you using encryption: No
Are you using an external user-backend, if yes which one: No
Browser: Google Chrome Version 72.0.3626.119
Operating system: Windows 7 64-bit
Thank you, this helped me also upgrade from owncloud 10.1.0 to nextcloud 12.0.13.
I have also successfully used instructions here. +
Thanks for the feedback, it's good to know this method is working for other people too.
FWIW, the same method seems to still be working with the combination of owncloud 10.1.1.1 / nextcloud 12.0.13.2. Thank you very much, @Addy771!
This also worked for me, and I've also successfully upgraded to later versions. This should be added to the actual migration manual!
the following helped me to migrate owncloud 10.2.0.5 to nextcloud:
Closing as it works with provided steps and info on this thread! Thanks everyone!! :hugs:
Hi @all, tried out to update along the above scenario here and get stuck....
I tried to upgrade from OC 10.2.1.4 and want to ask if anyone has done this with success? Post above describes only for OC 10.2.0
You'll have to give some info _where_ you get stuck, provide some error messages or logs or _any_ kind of info if you want people to be able to help you.
So you did: Changing version.php by adding '10.2.1.4' => true in section owncloud?
Any clue when this will be supported without the hack? I ran into the same problem trying to migrate from ownCloud 10.2.1 to Nextcloud. I'll stick with ownCloud until this is supported without manually modifying the database.
@EgbertW, the Issue has been closed by @skjnldsv. Perhaps better to open a new one requesting support for a specific combination of releases?
I noticed it has been closed, but I don't see any actual resolution. And I don't expect it to come from the NextCloud 12 release, actually, as that is an unmaintained release. The main problem is that the update server of NextCloud states that to migrate from OwnCloud 10.1.x or 10.2.x, you need to download NextCloud release 12. But NextCloud 12 doesn't support upgrading from these newer versions of OwnCloud, so I guess this migration feature needs to be updated in the current release of NextCloud and the update server needs to start suggesting a newer release.
I'm fine with starting a new issue, but the contents will be the same as no actual fix has been implemented, except for doing more manual work.
Or is the official stance of NextCloud: migrating from OwnCloud >= 10.1.0 is not supported without manually editting version.php file and manually modifying the database? In that case, maybe the guide on https://nextcloud.com/migration/ should be updated to reflect that.
I guess there is no upgrade path from OwnCloud 10.1.x or 10.2.x to Nextcloud without manual steps. Your summorized the current state quite well. Nextcloud 12 is EOL so another release is unlikely but a direct migration to Nextcloud 15 is not possible.
@nextcloud/server-triage what do you suggest? Sure the migration is a one-time action but there should be some kind of documentation or automation for this case.
It's on my todo to look for a solution that allows migrating to a newer nextcloud. Unluckily this involves a lot of testing and risk for the data, also basically we need to run the upgrade steps from nc12 to nc17, although you are on 17. That makes it a bit complicated.
Also we have to check for the database and php versions on the way. Because making a migration where you have to replace the database or php version is not the best idea.
@nickvergessen That does sound like it makes it a lot more complicated. It really all depends on the desire to keep supporting migration paths from ownCloud. Currently it seems that it is a recommended / supported migration, but it currently fails when you come from an up-to-date ownCloud version.
In my case, it's slightly more painful as I'd thought: let me do the migration to NextCloud today. I should probably first start with upgrading ownCloud to the latest version. I was coming from 1.0.2 from which the migration to NextCloud seems to be supported. Only after I verified that the upgrade to 10.2.1 succeeded and removed the backups I found out that I'd be better of not having done that.
Anyway. Given the complexity of supporting the migration from OC in NC17, is it totally unthinkable to consider doing another minor upgrade to NC12, with the only change adding migration support from OC >= 10.1.0? And if it is, maybe it can be considered to update the script linked to in the migration guide ( https://download.nextcloud.com/server/installer/migrator/index.php ) to automate these steps when OC >= 10.1.0 is detected?
Is it not in many cases required to upgrade PHP an DB to be able to run NC17 in the first place, anyways?
I followed all the steps and I got this message:
This version of Nextcloud is not compatible with > PHP 7.2.
You are currently running 7.2.19-0ubuntu0.18.04.2.root@owncloud:/var/www/owncloud#
I have Ubuntu 18.04 with php7.2
I will try to migrate the installation to ubuntu 16.04 and do the same
https://askubuntu.com/a/1048588
(https://launchpad.net/~ondrej/+archive/ubuntu/php)
Here to tell you that I installed owncloud 10.2.1 on ubuntu 16.04 ... A virtual machine that I had previously configured. I updated to 12.0.13, but with problems in the database that I could solve by doing a google search, then I updated to the latest version 13. Then I switched to ubuntu 18.04 with php 7.2 and updated to 14, then 15 and then 16 .
This manual method still works ... And I dare to say that it is safe, I keep all public links shared with other users, which were quite a lot. And I have all the same apps
https://askubuntu.com/a/1048588
(https://launchpad.net/~ondrej/+archive/ubuntu/php)
Thanks @sixtyfive ... I do not recommend downgrading a php version in the same installation. I tried it myself and dozens of things have been broken.
Thanks @sixtyfive ... I do not recommend downgrading a php version in the same installation. I tried it myself and dozens of things have been broken.
oh, good to know. not using debian-based distros myself anymore, but still - good to know!
I switch between several php versions daily. I have them installed all in parallel, to test features/bug-fixes on 5.6 to 7.3 did not yet receive a problem, but well that is exactly the reason for my comment above
I tried to upload to PHP 7.1 on Ubuntu 16.04 years ago. I had a working owncloud there that stopped working and I had to go back to the snapshot I had. Surely something in particular with the operation of owncloud in that particular version, which already recommended php 7.1. But the same thing happened to me with roundcube in Debian Jessie. In Debian Strech I uploaded a php version without a problem. Then I realized that there are a number of things that break in that migration, that sometimes it works and sometimes it doesn't, and that with a clean and stable installation, in any case, it always works.
That's why I didn't downgrade php version in Ubuntu 18.04, what I did was migrate my owncloud that I had to an old ubuntu 16.04 installation, where I also had owncloud running until a few months ago.
Report that owncloud 10.2.1 still works on Ubuntu 16.04 with the distribution packages, including php 7.0 and that way I was able to migrate to Nextcloud 12.0.13, with errors in updating the database that fixes in the same database of data, without moving it from site. I have the database on a separate server with Debian Buster and mariadb 10.3 and it is compatible with owncloud and with Nextcloud, you don't have to migrate anything.
The migration to Nextcloud 13 was done in ubuntu 16.04 still with php 7.0
The migration to NC 14 and I did it in ubuntu 18.04 with php 7.2 and from version to version 16 that works great
I have tried to follow as close as possible to migrate my OC 10.3 to NC 12.0.3, after running the SQL commands, I end up now in this nasty error right after "Set log level to debug" and "Updating database schema":
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'ALTER TABLE oc_filecache CHANGE `fileid` `fileid` INT AUTO_INCREMENT NOT NULL, CHANGE `parent` `parent` INT DEFAULT 0 NOT NULL, CHANGE `mtime` `mtime` INT DEFAULT 0 NOT NULL, CHANGE `storage_mtime` `storage_mtime` INT DEFAULT 0 NOT NULL':
SQLSTATE[HY000]: General error: 3780 Referencing column 'file_id' and referenced column 'fileid' in foreign key constraint 'FK_F0C3D55B93CB796C' are incompatible.
Update failed
Does anyone have a clue how to fix this mess? Thank you.
@boschma1 Yes, thats easy. Solved same issue at my end months ago. I assume you have a working backup, it's without warranty!
Find and double check the foreign key:
SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
-> FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
-> WHERE REFERENCED_TABLE_SCHEMA = 'owncloud' AND REFERENCED_TABLE_NAME = 'oc_filecache';
Drop the foreign key:
ALTER TABLEoc_filecacheDROP FOREIGN KEYFK_F0C3D55B93CB796C;
I found solution refering this articel in the past:
https://help.nextcloud.com/t/solved-owncloud-to-nextcloud-migration-oc-accounts-foreign-key-constraint-fails/48635
Thank you. That solved my issue!
Hello, I'm really not into mysql a.s.o. Can you please give me a hint.
I'm not able to delete the foreign key. This is my Bash output:
`MariaDB [(none)]> SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
-> FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
-> WHERE REFERENCED_TABLE_SCHEMA = 'nextcloud' AND REFERENCED_TABLE_NAME = 'oc_filecache';
+---------------------+-------------+---------------------+-----------------------+------------------------+
| TABLE_NAME | COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+---------------------+-------------+---------------------+-----------------------+------------------------+
| oc_persistent_locks | file_id | FK_F0C3D55B93CB796C | oc_filecache | fileid |
+---------------------+-------------+---------------------+-----------------------+------------------------+
1 row in set (0.030 sec)
MariaDB [(none)]> ALTER TABLE oc_filecache DROP FOREIGN KEY FK_F0C3D55B93CB796C;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> use nextcloud
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [nextcloud]> ALTER TABLE oc_filecache DROP FOREIGN KEY FK_F0C3D55B93CB796C;
ERROR 1091 (42000): Can't DROP FOREIGN KEY 'FK_F0C3D55B93CB796C'; check that it exists`
Great find, but for you that aren't so well-versed in SQL like Addy771 is, follow this:
sudo mysql
use your_database
(replace "your_database" with the name of your database. Usually this will be "owncloud". )
alter table oc_persistent_locks
drop foreign key FK_F0C3D55BC901C6FF,
drop owner_account_id;
alter table oc_persistent_locks
drop foreign key FK_F0C3D55B93CB796C,
drop file_id;
thank you @Addy771 I just upgraded from current Owncloud 10.0.x using the migration script and ran into this problem here. You saved me so many hours! I just wish the migration script would actually have done its job.
For info, following the initial post from @Addy771 (and running the additional alter table oc_persistent_locks drop foreign key FK_F0C3D55B93CB796C, drop file_id; sql statement at the end), I was able to migrate from the latest owncloud stable version 10.4.1.3 to Nextcloud 12.
Do note that you need to add the '10.4.1.3' => true, line in the owncloud array (not the nextcloud one) in version.php.
Most helpful comment
I guess there is no upgrade path from OwnCloud 10.1.x or 10.2.x to Nextcloud without manual steps. Your summorized the current state quite well. Nextcloud 12 is EOL so another release is unlikely but a direct migration to Nextcloud 15 is not possible.
@nextcloud/server-triage what do you suggest? Sure the migration is a one-time action but there should be some kind of documentation or automation for this case.