Moving Data Directory Fails NC30 Snap

Hi guys! I’m really struggling with changing the location of my data directory in Nextcloud, both per creation of admin and post.

For pre admin creation:
1)
$ sudo mkdir -p /media/nextcloud/data
$ sudo chown -R root:root /media/nextcloud/data
$ sudo chmod 0770 /media/nextcloud/data

  1. Change the autoconfig.php file
    // …
    ‘directory’ => ‘/media/nextcloud/data’,
    // …

$ sudo snap restart nextcloud.php-fpm

I follow a similar process with pros admin, I also copy the files over.
I got these steps from this tutorial: Change data directory to use another disk partition · nextcloud-snap/nextcloud-snap Wiki · GitHub
and
Wiki Change data directory · nextcloud-snap/nextcloud-snap Wiki · GitHub

For both I get this error: “Your data directory is invalid. Ensure there is a file called “.ncdata” in the root of the data directory. It should have the content: “# Nextcloud data directory””

The .ncdata file along with the rest are located in the new data directory and all the files have root permissions.

Any ideas? Am I missing something?

Did you give the snap access to removable media as noted in the prerequisites?

1 Like

are you sure the error refers to .ncdata ? that is strange :thinking:

2. Connect media to snap

Connect removable media

Removable media must be mounted to either /media or /mnt as root with root permissions and connected to Snap!

sudo snap connect nextcloud:removable-media

4. Path to data directory

By default, the data directory in Nextcloud snap is .../data!

'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data'

So regardless which procedure is used, the path to the data directory must include the complete path including .../data because this is where the required .ocdata file is located.

Common error message for incorrect path in config file

Error
Your data directory is invalid.

Ensure there is a file called ".ocdata" in the root of the data directory.

have you created the admin-user? see

b) Define data directory before installation (admin-user needs to be created) in /var/snap/nextcloud/current/nextcloud/config/autoconfig.php


please be clear, “similar” process?


your step 3 is incorrect, its no use only restarting FPM, you must restart the snap sudo snap restart nextcloud

1 Like

I have the same problem. Went through the same manual, connected removable media. Got the error "Your data directory is invalid.

Ensure there is a file called “.ncdata” in the root of the data directory. It should have the content: “# Nextcloud data directory”"

I’ve also ran sudo /snap/bin/nextcloud.occ config:list and got this:

Your data directory is invalid.
Ensure there is a file called “.ncdata” in the root of the data directory. It should have the content: “# Nextcloud data directory”

Cannot create “data” directory.
This can usually be fixed by giving the web server write access to the root directory. See Introduction — Nextcloud latest Administration Manual latest documentation

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /snap/nextcloud/46218/htdocs/lib/private/Console/Application.php:137
Stack trace:
#0 /snap/nextcloud/46218/htdocs/console.php(81): OC\Console\Application->loadCommands()
#1 /snap/nextcloud/46218/htdocs/occ(11): require_once(‘…’)

@CloudsHead and @Mikhail_Reshetnikov,

may I suggest creating an issue on our GitHub · Where software is built and be sure to complete the bug report (the more information the better)

see Getting help

this;

is possibly the issue here

Noone could’ve predicted it, but while trying to re-create the problem for the github issue form, I’ve went through all the steps once more and managed to avoid the problem.
I used this manual to change the directory: Change data directory to use another disk partition · nextcloud-snap/nextcloud-snap Wiki · GitHub
I gave nextcloud access to media thingy as the readme suggests.
I’m not sure what I did differently. My only suggestion would be to be extra attentive when copying the data folder. Cause I did this previously:
sudo mv /var/snap/nextcloud/common/nextcloud/data /mnt/chest/storage/data

and it didn’t work.

This time I did this:

sudo mv /var/snap/nextcloud/common/nextcloud/data /mnt/chest/storage

So this might be the issue here. Anyway, thank you for your help a lot!

1 Like

@Mikhail_Reshetnikov thanks for that…

yeah, that’s happened to everyone I guess… :rofl:

Would you agree its not a snap issue then, but rather an OS thing?
or
Do you see an issue in the docs?


@CloudsHead Please confirm that you’ve got Requirements covered. And try this Change data directory to use another disk partition · nextcloud-snap/nextcloud-snap Wiki · GitHub again step by step…

Please show us what’s in that directory… sudo ls -al /media/nextcloud/data

I’m guessing we’ll see data in there… so your path will need to be
'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data/data' where you’ll find .ocdata:thinking: and not .ncdata

I’ve never heard on .ncdata but I stand to be corrected

@scubamuc

This is most definitely not a snap issue, it’s my inattentiveness.

As having /data at the end of both ends of the paths is kinda intuitive for a noob (and wrong), I’d suggest maybe adding a small warning about that in the doc… But I’m not sure if it’s not just two of us who made this mistake.

In any case, the docs are not wrong and everything works if you follow them precisely.

1 Like