Reinstall using existing data-dir and user names

I am planning on migrating my Nextcloud installation to a new VM and came across an issue while testing the installation.

By setting --data-dir to an existing nfs share and using the same username as the original installation, it failed with the following error:

Username is invalid because files already exist for this user

I think it may be related to this change: https://github.com/nextcloud/server/pull/18130

Is there a recommended procedure for using the existing data with the same usernames in the new install?

Full command used to install:

php occ maintenance:install --database mysql --database-name my_db_name \
    --database-user my_db_user --database-pass my_db_pass --admin-user admin_user \
    --admin-pass admin_pass --data-dir /path/to/nfs/share

+1. Iā€™m running into the same problem. Did you ever find a solution @chuckn246 ?

@skidelo
Maybe it is better to open an own thread.

If I were you, I would install Nextcloud completely empty, create the users manually, etc. Then I would copy (or mount) the data back into the datadirectory structure, and then re-load the files/directory in Nextcloud database with

sudo -u www-data /path/to/nextcloud/occ files:scan --all
documentation