Nextcloud Update Problem

I prefer to have the nextcloud data directory not in the webroot of the nextcloud server.
Nextcloud webroot and data directory - best practices on Ubuntu 18.04 LTS

try the following steps:

stop all nginx, database redis tasks
systemctl stop nginx …

  1. make a directory somewhere outside the path /var/www/nextcloud → maybe /media/nextcloud/my-data-dir
  2. change ownership of this new data dir → sudo chown -R www-data:www-data /media/nextcloud/my-data-dir
  3. copy all (!) hidden and no-hidden files of your actual data dir /var/www/nextcloud/ncdata to /media/nextcloud/my-data-dir
  4. zip your old ncdata dir as backup if something needs to be restored later (!)
  5. move the zip file away from /var/www/nextcloud and delete your ncdata folder
  6. edit your /var/www/nextcloud/config/config.php datadirectory path to your new path /media/nextcloud/my-data-dir
  7. repeat the command sudo chown -R www-data:www-data /media/nextcloud/my-data-dir to be sure that all files and folders are owned by your webserver user and also check that www-data user has read/write access to all files and folders (!)
  8. start the nginx, database, etc.
  9. run command sudo -u www-data php /var/www/nextcloud/occ integrity:check-core

Login to your WebUI and enter the Admin section and re-check if everything works fine.