Migrate users to new install

Is there a way to migrate users to a new install?

I have an existing nextcloud installation which will refuses to update. I need to move this to a new server and wish to migrate the 30+ users and passwords that I have already to a fresh install.

I don’t need to migrate any files - users can only view files shared by admins and are configured to not be able to upload their own.

Old server is running version 13.01
New server is running 17.01

I have tried importing the following tables which seem to contain user related info
oc_users
oc_addressbooks
oc_accounts
oc_groups
oc_group_admin
oc_group_user

Unfortunately this generates a server error and I cant log in with either an admin or user account.

Any ideas?
Is this possible?

I believe you need to set a new server with 13.01, restore your DB from initial Server and do all major versions update till 17…

Thanks - this was indeed way to do it.
For others benefit who may want to do the same:

  • used web installer (with modified setup-nextcloud.php. ) to install of old version.
    Needed to change setup-nextcloud.php replacing // Nextcloud version define(‘NC_VERSION’, ‘17.0.1’); with // Nextcloud version define(‘NC_VERSION’, ‘13.0.1’);
  • Dropped following tables in phpmyadmin and installed copies from old server
    oc_users
    oc_addressbooks
    oc_accounts
    oc_groups
    oc_group_admin
    oc_group_user
  • Incremental in app update of all Nextcloud versions through to 17.0.1

Worked perfectly - all user details and groups preserved

1 Like

Hello from France. Thanks for this thread, that is exactly what i’m looking for. I need to migrate too the users from one serveur to another with a new instance. The old one is 17 and the one new too obviously. Both are up to date, nonetheless, the old one is a “classique” architecture with mysql and phpmyadmin, and the new one is built with Docker (and docker-compose) and mariadb with containers, for increased performance and easiest maintenance. My questions :

  • any incompatibilty between mysql and mariadb tables to migrate these users tables ? I don’t think so but not sure…
  • could you please show me what commands and synthax you used for that operation ? I guess it is DROP TABLE for each one to export… Then what to do ? The commands create a file ?? I take this file to put it where ? How can I can do the import on my mariadb container then ?

I precise my mariadb container has an external folder, on the host (Ubuntu serveur). I suppose i put the files here and within the container with docker exec i import them ? What commands ?

Thanks a lot for your replies and your lights which will help many of us I think.

Check this out, it seems nothing to change, only please check mySQL and MariaDB Versions: Migration from MySQL to MariaDB

:slight_smile: do not think so, you can backup and restore you DB in a new server, especially if you have only those 2 users. Please read whole docu there.

Thanks for your advices.
I figured it out.

Connect to mysql : mysql -u root -p nextcloud
netxcloud -> name of your nextcloud instance (nextcloud in my case)

Commands for dumps (export) :

mysqldump -u root -p nextcloud oc_users > /mnt/oc_users.sql;
mysqldump -u root -p nextcloud oc_addressbooks > /mnt/oc_addressbooks.sql;
mysqldump -u root -p nextcloud oc_accounts > /mnt/oc_accounts.sql;
mysqldump -u root -p nextcloud oc_groups > /mnt/oc_groups.sql;
mysqldump -u root -p nextcloud oc_group_admin > /mnt/oc_group_admin.sql;
mysqldump -u root -p nextcloud oc_group_user > /mnt/oc_group_user.sql;

It will create .sql files in /mnt/ (you can choose any folder on the host, it’s your choice).

Copy those file in your new server in /mnt/ (on the host).
I transfer the files from one to the other via WinSCP.

Commands for the import (via docker-compose) :

docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud < /mnt/oc_users.sql
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud < /mnt/oc_addressbooks.sql
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud < /mnt/oc_accounts.sql
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud < /mnt/oc_groups.sql
docker-compose exec -T db mysql -unextcloud -pXXXXXXXXnextcloud < /mnt/oc_group_admin.sql
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud < /mnt/oc_group_user.sql

db = service name in docker-compose
-unextcloud = user
-pXXXXXXXX = pass
nextcloud = name of the instance

In docker-compose, it matches with the env variables :

  • MYSQL_PASSWORD=
  • MYSQL_DATABASE=
  • MYSQL_USER=

After that, it’s done.
Go in Web-app, all the users account are here and safe, with passwords. No problem to connect with these accounts.

Except one thing. The e-mails are not there.
I’ve found that these users accounts e-mails are in oc_preferences table.
But my dump with that table creates an empty file. Never found why…
Nevermind, I’ve done this manually.

I don’t know how mjoldman had success with e-mails because, they are in oc_preferences table.
It was a detail for me, so nevermind.

No incompatibility between export mysql and import mariadb in my case.

2 Likes