Destroyed database - installed fresh - how do I map existing users to their existing files?

Nextcloud version: 24.0.10
Operating system and version: Debian Buster
Apache or nginx version: Apache 2.4.38
PHP version: 8.1-fpm

The issue you are facing:
I upgraded my server from Stretch to Buster and had to manually upgrade postgresql from 9.6 to 11. Something went wrong, and I lost the entire database. I did not have backups (you know, for someone else you always take care of those, but for your own personal stuff you don’t…).

I have run the NC updater, and then ran through the installer with a new admin account, enabled all the apps, including the LDAP user backend. That created new folders in my data folder with the names of those users, but with a different UUID. I know how to re-map the users via the LDAP wizard (‘expert panel’), but I don’t know how to proceed with the actual contents of the previous user-folders…

  • Do I just move all files from the previous user-folder to the new user-folder?
  • Do I softlink the new user-folder to the old user-folder?
  • Do I have to used the occ tool to make sure that other mappings are corrected as well?

I think the most stable way would be copy file contents into new user folder and run occ files:scan to “import” the files into database…

Thx - I have already been pretty successful with these few commands:

For each individual user:

sudo -u www-data mv /srv/media/USER/* /srv/media/USER_old/
sudo -u www-data /usr/bin/php8.1 --define apc.enable_cli=1 occ ldap:reset-user -y WHATEVER_UUID_AS_USERNAME_WAS_GENERATED
sudo -u www-data mv /srv/media/USER_old/* /srv/media/USER/

And then once for all users:

sudo -u www-data /usr/bin/php8.1 --define apc.enable_cli=1 occ passwords:backup:restore 2023-03-01_08-44-34
sudo -u www-data /usr/bin/php8.1 --define apc.enable_cli=1 occ files:scan --all

Next up is to find the data (or backups) in the appdata_* folders and restore my contacts and calendars.