Mistake - Moving data

Hello folks,
I have my nextcloud 12 up and running within my VM using nginx.
It was working well but i wanted to move my data to my NAS.
I created a network sharing, it is working well so after that without any additional thinkin i tried to move my data folder to my shared folder ( /mnt/NextCloud/ ) after that my Nextcloud doesn’t work anymore.
I have run the script to fix permission. ( https://docs.nextcloud.com/server/9/admin_manual/installation/installation_wizard.html#strong-perms-label )
I have manually applied the right permissions to my data folder (using the instruction of the previous link).

Here is my config.php :

$CONFIG = array (
  'instanceid' => 'xxxxx',
  'passwordsalt' => 'xxxxx',
  'secret' => 'xxxxxxx',
  'trusted_domains' =>
  array (
0 => '',
1 => 'xxxxx',
  'datadirectory' => '/mnt/NextCloud/nextcloud-data/',
  'overwrite.cli.url' => '',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxxxx',
  'installed' => true,

My data folder :

root@nuci5:/var/www/nextcloud# ls -la /mnt/NextCloud/nextcloud-data/
total 76
drwxr-x---  5 www-data www-data  4096 May 28 22:20 .
drwxrwxrwx  4 www-data root      4096 Jun  3 22:00 ..
drwxr-x---  7 www-data www-data  4096 May 29 23:04 toto
drwxr-x--- 10 www-data www-data  4096 Jun  1 17:10 appdata_xxxxxxxxx
drwxr-x---  2 www-data www-data  4096 May 28 22:20 files_external
-rw-r--r--  1 root     www-data   324 May 28 22:10 .htaccess
-rw-r-----  1 www-data www-data     0 May 28 22:10 index.html
-rw-r-----  1 www-data www-data 48059 Jun  3 21:23 nextcloud.log
-rw-r-----  1 www-data www-data     0 May 28 22:10 .ocdata

And the error that i have in error.log :

PHP message: {"reqId":"xxxxxx","level":3,"time":"2017-06-03T20:42:50+00:00","remoteAddr":"","user":"--","app":"PHP","method":"GET","url":"\/status.php","message":"fileperms(): stat failed for \/mnt\/NextCloud\/nextcloud-data\/\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#122","userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.1 (build 8) (Nextcloud)","version":""}
PHP message: {"reqId":"xxxxxx","level":4,"time":"2017-06-03T20:42:50+00:00","remoteAddr":"","user":"--","app":"remote","method":"GET","url":"\/status.php","message":"$absolutePath must be relative to \"files\"","userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.1 (build 8) (Nextcloud)","version":""}
PHP message: PHP Warning:  fileperms(): stat failed for /mnt/NextCloud/nextcloud-data//nextcloud.log in /var/www/nextcloud

I don’t know how i can fix it.
After some reading it seems to be a very bad thing to simply move the data directory using a simple mv and editing the config.php but now it’s too late :confused:
Do you know how i can fix this ?


I think first and foremost you need to edit the config.php to remove that trailing slash:

'datadirectory' => '/mnt/NextCloud/nextcloud-data/',
'datadirectory' => '/mnt/NextCloud/nextcloud-data',

As it’s showing more than one / in the error there.

If that doesn’t resolve it, and in honesty it’s probably better that you:

  • Return the datadirectory line in config.php back to what it was
  • Create a symlink from the original location to the new location

(Note I’m not telling you to move the data back, just edit the config and create a symlink)

That would fall inline with the “official” method for moving the data directory and doesn’t require editing the database.

This comment is made on the assumption your NAS is linux based, mounted in a linux-friendly way and as such listed permissions actually mean something.

Hello Jason,
Thanks for your answer.
I have tried to edit it as it was before, it is working.
My NAS is linux based it is a Synology with NFS share ( /mnt/NextCloud nfs defaults,user,auto,noatime,intr 0 0 )

I will do a backup of my VM and i will try to delete nextcloud and reinstall it correctly using the good data folder directly, it will probably be the best choice to have a “proper” setup.

If you’re just setting up now and don’t mind the reinstall then absolutely, go for it.
As mentioned though, the symlink directory move is “supported” should you ever need to do it again.

NFS is great, just ensuring it wasn’t something wacky :slight_smile:

Thanks a lot for your support.
I have just finished my reinstall and everyting is working fine now.
Sure your question totally make sense :slight_smile:
I will take a look on how i can correct the remaining errors

php does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.
Please check the installation documentation ↗ for php configuration notes and the php configuration of your server, especially when using php-fpm.

The "X-Frame-Options" HTTP header is not configured to equal to "SAMEORIGIN". This is a potential security or privacy risk and we recommend adjusting this setting.

No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.
The PHP Opcache is not properly configured. For better performance we recommend ↗ to use following settings in the php.ini:


And i will perform the nextcloud security check to make sure :smile: i am looking for the A+ but i think to correct this before.

Excluding the PHP error which I’d have to Google (and thus likely faster if you Googled it yourself) the remaining issues are all documented in my guide, feel free to run through and make changes as required:

1 Like

Thanks, i will look at your tutorial :wink: and of course i will google the remaining issue and ask for help if needed.