Koozali.org formerly Contribs.org

Nextcloud Database transfer

Nextcloud Database transfer
« on: May 12, 2020, 01:27:40 AM »
Hi. I have had to reinstall my SME-Server because my Nextcloud broke and I couldn't fix it.
On reinstalling Nextcloud, I accidently chose the default database of SQLite instead of MySQL. I want to use MySQL and have looked at the options and I have not been able to figure out how to transfer the database.

Is there an easy way to do this? The Nextcloud site simply states "php occ db:convert-type [options] type username hostname database". I assume in SME, I just use 'OCC'. Is this safe to do this on SME? Do I use the username that I can find in PHPMyAdmin?

Or, is there a way of doing the transfer through PHPMyAdmin? I don't want to break my fresh install.

I have spent days looking through the forum and How-To's and haven't found a way of doing this.

Apologies if this is something that I have missed.


Offline mmccarn

  • *
  • 2,499
Re: Nextcloud Database transfer
« Reply #1 on: May 12, 2020, 01:33:12 PM »
Nextcloud looks pretty confident that their db:convert tool will convert your database:

My assumption is that the username and password should be the values used when you created the new database.

If you're using a non-standard version of mysql, you may need to customize the value of "--port", customize the settings for the mysql service, or both (The mysql5.7 contrib needs some re-configuration after installation before it will respond on a TCP port)

If you installed Nextcloud using the SME Nextcloud contrib, make sure the username and password for your database match the values in the configuration db (since those values will overwrite the values in the config file whenever you run signal-event nextcloud-update).

On a VM, I'd make a backup before starting...  On a physical server, I would locate the sqlite database and make sure I have a backup of the nextcloud application, configuration, data, and the sqlite database (just in case...).  I used to move the actual content to a new/safe location, then copy it back to the original location before running updates on systems that made me nervous.

Re: Nextcloud Database transfer
« Reply #2 on: May 12, 2020, 03:04:18 PM »
Thanks for the reply. I will do as you say. I have had trouble finding the SQLite database, but I will do the backup before doing the conversion (tomorrow for me, as it is night, now, in Australia).

Offline mmccarn

  • *
  • 2,499
Re: Nextcloud Database transfer
« Reply #3 on: May 13, 2020, 02:31:43 PM »
I did this out of curiosity:
- install nextcloud on a base up-to-date VM using instructions from the wiki
  * this left the system running mysql, with lots of useful sme-specific configurations in place

- attempt to run OCC db:convert-type to convert to sqlite3, but this generated errors about "no such table: oc_appconfig" (in case this actually did something before erroring out)

- rename /usr/share/nextcloud/config/config.php as config.php.org

- browse to nextcloud URL and complete the setup using sqlite3
  * login using username='nextcloudadmin' using the value of 'AdminPassword' from config show nextcloud as the password
  * this created /usr/share/nextcloud/data/owncloud.db [sic]

- converted the sqlite database back to mysql
  * get the dbuser, dbname, dbpassword configured by the contrib install using
    config show nextcloud

  * run the db:convert-type command
    OCC db:convert-type --clear-schema mysql nextcloud localhost nextcloud
  ( where nextcloud is the username, localhost is the hostname, and nextcloud is the database)

  * copy & paste the full value of 'DbPassword' from the 'config show' command above when prompted

I now have a working nextcloud on my test server using mysql -- but I have lost the LDAP integration and memcache configuration

Re: Nextcloud Database transfer
« Reply #4 on: May 14, 2020, 07:57:17 AM »
Thanks for that. I appreciate your effort. I have been busy and haven't done anything yet.
The information about the conversion is great. As soon as I get an opportunity, I will back up the Nextcloud folders and database and do a conversion and give feedback as to whether things worked well.

Re: Nextcloud Database transfer (SOLVED)
« Reply #5 on: May 15, 2020, 08:58:54 AM »
I got some time to perform the database transfer and this all worked beautifully.

I have not found any other issues with SME or Nextcloud following the transfer.

Thanks very much for the help and amazing that you went ahead and did a trial transfer to make sure of the process.

« Last Edit: May 15, 2020, 09:02:48 AM by gavan_white »

Offline ReetP

  • *
  • 2,434
Re: Nextcloud Database transfer (SOLVED)
« Reply #6 on: May 15, 2020, 03:32:19 PM »
Thanks very much for the help and amazing that you went ahead and did a trial transfer to make sure of the process.

That's cos he's a star!!
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation