Migrating from ownCloud 9.1 to NextCloud 9.0

Submitted by Tha-Fox on 2016-08-03

After I read about Frank Karlitschek leaving ownCloud, Inc. and creating Nextcloud, I've been pondering whether I should migrate to Nextcloud or continue using ownCloud. The latter has been working for me just fine except the Music app, which I've replaced with Youtube. As a home user, the enterprise features aren't my concern, either. The best comparison I found was also a bit vague.

I did a bit of research and found out that all of the third party apps should work as is on Nextcloud too. That is the current situation but it may change once the two projects start heading to different directions. Since I use Arch Linux that moves forward pretty fast, I thought that this is the right time for me to do the migration.

Because I install all that I can from the Arch Linux default repositories and AUR, the migration I did was not officially supported by Nextcloud. My ownCloud that was installed from community repository, had version 9.1.0.15. The Nextcloud version offered from AUR was 9.0.53.0. The supported paths are ownCloud 8.2 or 9.0 -> Nextcloud 9. Those who are using ownCloud 9.1 (me, myself & I), should wait for Nextcloud 10 which is currently in beta phase. So if you want to go by the book (which you definitely should), then don't read on.

The process I describe here is for my own environment so if you follow this you may have to change some paths etc. My stack consists of Arch Linux, MariaDB, nginx and php-fpm. To install packages from AUR I use yaourt. I have also made backups of my environment before starting the migration.

The first thing was to set the maintenance mode on so that the environment is in a steady state.

 

sudo -u http php /usr/share/webapps/owncloud/occ maintenance:mode --on

Then it's time to do a backup once more (because you skipped it in the beginning, didn't you?).

 

mv /etc/webapps/owncloud /etc/webapps/owncloud.bak

mv /usr/share/webapps/owncloud /usr/share/webapps/owncloud.bak

Next it was time to remove the ownCloud package, add key for Nextcloud package in AUR as root and install it.

 

pacman -R owncloud

pacman-key --recv-key D75899B9A724937A

yaourt -Syua nextcloud

 The installation package creates automatically two directories, /usr/share/webapps/nextcloud and /etc/webapps/nextcloud. We will move them to the original directory name (owncloud), remove the config and data directories within the former directory and replace those from the backups we created earlier.

 

mv /usr/share/webapps/nextcloud /usr/share/webapps/owncloud

mv /etc/webapps/nextcloud /etc/webapps/owncloud

rm -rf /usr/share/webapps/owncloud/config

rm -rf /usr/share/webapps/owncloud/data

rm -rf /etc/webapps/owncloud/config

mv /usr/share/webapps/owncloud.bak/config /usr/share/webapps/owncloud/

mv /usr/share/webapps/owncloud.bak/data /usr/share/webapps/owncloud/

mv /etc/webapps/owncloud.bak/config /etc/webapps/owncloud

The next step is to fix the permissions. I use http as my nginx user, yours might be different.

 

chown -R http:http /usr/share/webapps/owncloud/config

chown -R http:http /usr/share/webapps/owncloud/data

chown -R http:http /etc/webapps/owncloud

 The last thing before the actual migration is to edit the version ownCloud thinks is installed. If you skip this step, you will end up with an error stating that downgrading the version is not supported. So user your favorite editor to edit the file /usr/share/webapps/owncloud/config/config.php, find a row that says something like 'version' => '9.1.0.15' and change it to '9.0.52.0'. Then it's time to finally do the migration. We first restart the web server and then run the migration. Here is an example output from my migration.

 

systemctl restart nginx

sudo -u http php /usr/share/webapps/owncloud/occ 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
Set log level to debug
Checking whether the database schema can be updated (this can take a long time depending on the database size)
Checked database schema update
Checking updates of apps
Checked database schema update for apps
Updating database schema
Updated database
Disabled 3rd-party app: calendar
Disabled 3rd-party app: contacts
Update 3rd-party app: calendar
Update 3rd-party app: contacts
Starting code integrity check...
Finished code integrity check
Update successful
Maintenance mode is kept active
Reset log level

The maintenance mode is still on as you can see from the end of the output. So we will set the maintenance mode off.

 

sudo -u http php /usr/share/webapps/owncloud/occ maintenance:mode --on

And that's it! After this I uninstalled ownCloud app from my Android phone and replaced it with Nextcloud app. AFAIK the iOS app is coming in the future.

Troubleshooting

Here are some errors I encountered.

  • Error:

    Cannot write into "config" directory!
    This can usually be fixed by giving the webserver write access to the config directory

    See https://docs.nextcloud.org/server/9.0/go.php?to=admin-dir_permissions

  • Fix: Check that the config directories exist under /etc/webapps/owncloud and /usr/share/webapps/owncloud and that the http user owns them.

  • Error: An unhandled exception has been thrown:
    OC\HintException: [0]: Downgrading is not supported and is likely to cause unpredictable issues (from 9.1.0.15 to 9.0.53.0) ()

  • Fix: Edit config.php as described above.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.