Error: "Username is invalid because files already exist for this user"

Nextcloud version (eg, 20.0.5): 22.2.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 Focal
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18.0
PHP version (eg, 7.4): 7.4.3
Database: MariaDB 10.3.31

System installed from scratch (new SSD). Nextcloud runs flawlessly after installation. [Admin > Overview > Security & setup warnings => All checks passed.]
Intended to run only within the LAN. No access to outside world.
Backup from old installation available (Nextcloud 22.1.1.2) but not yet restored.

1st attempt of user creation:

  1. Create new user with identical user name as old installation: “Users | New user”
  2. Chose identical password for this user as old installation
  3. Found out that due to the password policy old password is not valid (only the constraint that min. password length of 10 characters was infringed)
  4. Changed password policy in “Settings | Security | Password policy | Minimum password length”

2nd attempt of user creation:

  • User created as per step 1 & 2 from above
  • Newly created user was not able to login to Nextcloud
  • Login as Nextcloud admin and deleted new user

Issue I’m facing:

  • User that was created & deleted before cannot be created again. Error message box appears for half a second in upper right corner of Nextcloud web interface:
    An error occurred during the request. Unable to proceed. Username is invalid because files already exist for this user.

=> My hypothesis is that my iPhone synced via webdav in the meantime. I simply forgot to deactivate syncing. Indication: My iPhone calendar entries are gone & its address book is messed up.

BernieO’s tool calcardbackup was not able to backup any calendars/contacts because there is nothing from any user.

Questions:

  1. Is there a way to get hold of the data (calendar/contacts) that was received from my iPhone?
  2. How can I prevent in future that a newly connected webdav client (e.g. phone/tablet) of a newly created Nextcloud user gets deleted (loses its calendar/contact entries)? => i.e. populate only from device to nc on first connect.
  3. How can I create this user? Restore from backup would be one option but is there another way?

Thanks a lot in advance.
Cheers
George

The output of your Nextcloud log in Admin > Settings > Logging:

[ocs_api] Error: Failed addUser attempt with invalid argument exeption.

POST /ocs/v2.php/cloud/users
from 192.168.1.13 by ncadmin at 2021-11-08T14:36:21+01:00
0. /var/www/nextcloud/lib/private/User/Manager.php - line 396:
   OC\User\Manager->createUserFromBackend()
1. /var/www/nextcloud/apps/provisioning_api/lib/Controller/UsersController.php - line 410:
   OC\User\Manager->createUser()
2. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 217:
   OCA\Provisioning_API\Controller\UsersController->addUser("*** sensiti ... *")
3. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 126:
   OC\AppFramework\Http\Dispatcher->executeController()
4. /var/www/nextcloud/lib/private/AppFramework/App.php - line 156:
   OC\AppFramework\Http\Dispatcher->dispatch()
5. /var/www/nextcloud/lib/private/Route/Router.php - line 301:
   OC\AppFramework\App::main()
6. /var/www/nextcloud/ocs/v1.php - line 62:
   OC\Route\Router->match()
7. /var/www/nextcloud/ocs/v2.php - line 23:
   require_once("/var/www/nextcloud/ocs/v1.php")