Moving nextcloud data directory to external hard drive causes the mobile and dsktop app to fail

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5):28.0.1
Operating system and version (eg, Ubuntu 20.04): `RPi OS Bullseye
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.56
PHP version (eg, 7.4): 8.2

The issue you are facing:

I have successfully installed  NextcloudPi following the steps shown here "https://pimylifeup.com/raspberry-pi-nextcloud-server/". I have also successfully mounted an external hard drive (exfat) using this guide "https://pimylifeup.com/raspberry-pi-mount-usb-drive/". I included the relevant app on nextcloud and can access the files of my external hard drive from the nextcloud web ui, my android app and the desktop app. My next goal would be to move the nextcloud data directory to the external hard drive. To do this I took the steps below:
 1. I created a relevant folder on my external hard drive "sudo mkdir -p /mnt/nextcloud/data"
 2. I moved the files under the data directory to the new folder "sudo mv -v /var/www/nextcloud/data /mnt/nextcloud/data"
 3. I changed the owner of the new folder to www-data "sudo chown -R www-data:www-data /mnt/nextcloud/data"
 4. I changed the mode of the external folder to 0770 "sudo chmod 0770 /mnt/nextcloud/data"
 5. I changed the config file under "/var/www/nextcloud/config/config.php" so that the datadirectory points to the external folder

However after I did this my web ui continues to work, but both the android and desktop apps stop working (the android app gives an error message saying the server is under maintenance, while the desktop app just refuses to connect)

Is there anything I can do to fix this?

Thank you

Is this the first time you’ve seen this error? (Y/N): Y

The output of your Nextcloud log in Admin > Logging:

Error	no app in context	
Exception
HMAC does not match.
Could not decrypt or decode encrypted session data

4 Jan 2024, 13:20:32	

Warning	no app in context	
Login failed: panayiotis_karnezis@hotmail.com (Remote IP: 192.168.0.165)

4 Jan 2024, 13:19:47	

Warning	core	
Login failed: 'pana' (Remote IP: '192.168.0.165')

4 Jan 2024, 13:19:47	

Error	jsresourceloader	
Could not find resource files_external/js/public_key.js to load

4 Jan 2024, 12:03:46	

Error	jsresourceloader	
Could not find resource files_external/js/oauth2.js to load

4 Jan 2024, 12:03:46	

Error	jsresourceloader	
Could not find resource files_external/js/oauth1.js to load

4 Jan 2024, 12:03:46	

No older log entries available
Please note in the config file below I have changed a lot of the actual entries with "x"

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'MY_IP_ADDRESS',
  ),
  'datadirectory' => '/mnt/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '28.0.1.1',
  'overwrite.cli.url' => 'https://MY_IP_ADDRESS/nextcloud',
  'dbname' => 'DB',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'user',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
);

Moving one’s datadirectory requires extra steps:

https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#troubleshooting-data-directory