User data recovery to database

lower Nextcloud version: 21.0.1.1
higher Nextcloud version: 27.0.2.1

Ldap is not enabled in my version, why do the ‘oc_users’ table not correspond to the number of people in the organizational structure on the page? How should I add users under/nextcloud/data/to the ‘oc_users’ table? Because I need to migrate to another server,There is no user data in the table. After I migrate to another server, this user data will be lost. Although there is user data under the/nextcloud/data/folder, I cannot log in or create the same username on the new server. So, I would like to ask how to restore users who do not exist in the database ‘oc_users’ table to the table?

Are these old users that were deleted? Or if you know, if they can still login? You never used any external authentication method (ftp, smtp, …)?

Thank you very much for your reply. They have not been deleted and can still be logged in with a password in the old service center, but they have not been stored in oc_users table, I need to migrate it now. I don’t know how to migrate the data that is not in the table. Do you have any good suggestions?

what is the old service center? Some external authentication?

There may be a problem with my expression, I will explain it to you again.Now, I have two servers, one A and one B.The nextcloud version on server A is relatively low.The nextcloud on server B is the latest version.I am preparing to migrate nextcloud from server A to server B.I will migrate all ‘/nextcloud/data/’ folders from server A to server B, and at the same time, copy all the databases from server A to server B.During this process, I found that the users who could have logged in on server A were unable to log in on server B ,because oc_users table was no user data available on server B.There is also no such user data in server A.I haven’t started the ldap service either.So how should I recover these user data on B,How to use nextcloud on B like on server A?

I just checked out my test instance, where I used external authentication (ldap seems to be similar). Instead of having these accounts in oc_users, there is also a table with oc_accounts, do you see these users there?

If you want to reuse the database, you need to go through all the major upgrades to anticipate all the database modifications between the versions (NC21->NC22->…->NC27).

1 Like

The users in oc_accounts are the same as those in oc_users.The missing users did not appear in oc_accounts.How to find those users and migrate them?My ldap is not enabled, do I need to check where the configuration is? Here is my config.php file,Could you please help me check


Thank you very much

That is what I have seen with the external authentication app (IMAP, FTP, …) and from posts here, it seems to be the same way for LDAP. And there is also oc_users_external for the external users app. oc_storages should link the storage for users, do you find a hint for the other users?
I’d go through the tables a bit, perhaps it is linked to an app that allows to do so.

What is strange, you perhaps use the workin2gether app that was abandoned with NC12! Even for you now old version NC21 that was very old.

What apps are you using?

What is strange, if there are user logging in and they are not in the user database, how did they get access to your cloud, you probably didn’t create an account for them if not there would be an account.

I have uploaded several pictures, which are the comparison of all tables in the database,Comparison of Database Users and Page Users,And enabled applications.
I checked the database and found that table oc_users_external is not available.The data in oc_storages corresponds to the users in oc_users.
The matter is a bit urgent,I need your help.





In oc_group_us,The number of detected users is only 107, The number of users in the page organization structure is 117.These users are all from oc_users, and users that do not appear oc_users also do not appear in oc_group_us.

And in oc_storages, how many entries do you have with this style home::username? And a user that is not in oc_users, is there such a storage for them?

I’d pick one of the users that is not in the oc_users list, and check if the user can login, where the data is stored, and then try to trace back when the user was created, and/or check something common for these 10 users.

You can use the occ command for more details on the user as well:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#user-commands-label
the info should give you the user_id and the backend.

1 Like

In oc_storages,Users who are not in oc_users are not stored in this table.The total number of data in oc_storages corresponds to the number of data in oc_users.Users who are not inoc_users can also log in.Their actual storage locations are the same, but there is no data that does not appear in oc_storages.Only the existing users in oc_users will appear in oc_storages.

Can you check the occ command what it does (from my last post)?

Are you sure to work on the right database and not an old copy or backup?

I couldn’t find any relevant users on the original server.The command to query all users in the OOC command also cannot find users that do not appear in oc_users.