[NC19] How to move user data, without hickups

,

“P.S.” Part is only possibility to move data between the HDDs without even unmount it. E.g. when older disk dies and you can still move data to the new one.

Regarding ZFS, I belive you need to cleanup your /etc/fstab and live only needed parts, e.g. boot and with LVM.

@gas85,

I have looked in fstab file:

But i don’t know what do do here, as far as i know the nextcloud–vg-root and swap are necessary. And i am not seeing and ZFS references.

I have started my sql en apache and i got the error “make sure .ocdata is present in main directory”.

So i compared with my production NC, and the user data is not in the /mnt/ncdata directory on my test nextcloud. The files are in the /mnt/ncdata/ncdata.

So somewhere down the line i made a mistake. So i need to move the files from /mnt/ncdata/ncdata to /mnt/ncdata. i moved the files with this command:

mv -v /mnt/ncdata/ncdata/* /mnt/ncdata

@gas85,

So i moved the files, but i am still getting an error:

datafolder is invalid
make sure .ocdata is present in main directory
Your data directory is not writable

Rights can be restored by giving root write access to the folder on the webserver
https://docs.nextcloud.com/server/20/go.php?to=admin-dir_permissions.

So i think i need to give write access to root on the new /mnt/ncdata folder. Do you agree?

Is this the right thing to do?

sudo mount -a
sudo chmod -Rf 777 /mnt/data

Hey first of all check where you data folder configured, just find config.php in your NC folder, e.g.:

grep "datadirectory" /var/www/nextcloud/config/config.php
#Outup example
'datadirectory' => '/var/nextcloud/data',

you will see where it should be, then check if .ocdata is there:

ls -la /var/nextcloud/data/.ocdata
-rw-r----- 1 www-data www-data 0 Dec 14 09:31 /var/nextcloud/data/.ocdata

Usually you have like 660 for files and 750 for folders. Owner is your web user.


I’m not familiar with ZFS, but documentation says you have to use something like zpool remove to remove drives from the pool and then destroy it.

@gas85,

This gives me the correct result:

(COMMAND) grep “datadirectory” /var/www/nextcloud/config/config.php
(RESULT) ‘datadirectory’ => ‘/mnt/ncdata’,

But i cannot seem to locate the .ocdata file:
ls -la /var/nextcloud/data/.ocdata
ls -la /mnt/ncdata/.ocdata

Both gives me “No such file or directory”.
But when i look at my LIVE Nextcloud in the /mnt/ncdata directory, there is also no .ocdata file…

When i search for the file .ocdata:

(COMMAND) find/ -name .ocdata
(RESULT) /mnt/ncdata/ncdata/.ocdata

So that would mean the file didn’t move when i moved all the files (from /mnt/ncdata/ncdata to /mnt/ncdata). But when i “ls” in the folder /mnt/ncdata/ncdata it doesn’t show any files. Isn’t that weird?

So i used “mv -v /mnt/ncdata/ncdata/.ocdata /mnt/ncdata” . Now when i search for the .ocdata file, it shows me that the file is located in /mnt/ncdata. So that should be ok now.

When i try to open the nextcloud by browser, it only says now that the data directory is not writeable. So we went from 2 to 1 error :stuck_out_tongue:

@gas85,

With regards to the rights, i saw this website:

They say:

chown -R www-data:www-data /mnt/ncdata/

So you can set the premisson like “grouchysysadmin” written.

chmod 0750 /mnt/ncdata/ → ( 7|5|0 mean => user: rwx | group: rx | other: - )
w = write / r=read / x=execute / - = no premissions

In your case: chmod 0750 /mnt/ncdata/
maybe you have to set the same premission to every subdirectory.

find /mnt/ncdata/ -type d -print0 | xargs -0 chmod 0750

And every file in the data folder
find /mnt/ncdata/ -type f -print0 | xargs -0 chmod 0640
→ exept: .htaccess
chown root:www-data .htaccess
chmod 0644 .htaccess

Are you sure i should use “sudo chmod -Rf 777 /mnt/data”?

Noo, better

@gas85,

I did
chown -R www-data:www-data /mnt/ncdata
chmod -R 750 /mnt/ncdata

And it looks like it’s working. I can login, create folders and upload files :slight_smile:

My next problem was that updating is was not working. I fixed that with:
chown -R www-data:www-data /var/www/nextcloud

My only problem now is that settings tell me “there are errors in your setup” (translated from Dutch). But it doesn’t tell me what kind of errors.

I think i found the error, when i do sudo -u www-data php occ files:scan --all
It tells me that Home storage of user BLABLA is not writeable

I tried chmod 750 /mnt/ncdata and chmod 770 /mnt/ncdata, 750/770 doesn’t solve the problem.

1 Like

Glad that you made it. Regarding last error that’s strange. Did you did run chmod also with -R fir ncdata folder?

@gas85,

What do you mean? I used this commands:

chown -R www-data:www-data /mnt/ncdata
chmod -R 750 /mnt/ncdata
chown -R www-data:www-data /var/www/nextcloud

Which command should i try?

I think I misunderstood it. Everything looks fine.

@gas85,

But how do i fix this problem then?

When i do “sudo -u www-data php occ files:scan --all”

It tells me that “Home storage of user Operations is not writeable”

It shows that error for every user i have created.

I think based on chat above, you have to create an empty .ocdata file in a /mnt/ncdata/.

The only user the that gives me an error when i do:

“sudo -u www-data php occ files:scan --all”

Is my own account.

It tells me storage for user ME not writeable
Make sure you’re running the scan command only as the user the web server runs as.

My 5 others users are not giving the error anymore.

I got delete any recreate that user, not that big of a deal.
Is there a way to check if everything is working a 100% and is secure now?

After i rebooted, i am getting the same error:

Make sure there is a .ocdata in data directory

How do i create a new .ocdata file? Because using the old one doesn’t same to work.

I have seen on this topic ( Ensure there is a file called ".ocdata" in the root of the data directory - #6 by sin-ms ) that you can fix this issue by switching mode of Background jobs for NC18.

Tried that but it didnt work :frowning:

have you enter this line After recreate .ocdata file in /mnt/ncdata ??
chown -R www-data:www-data /mnt/ncdata

have you use this command with -R ? :
chmod -R 750 /mnt/ncdata

@Mageunic,

So i should do it like this?

chown -R www-data:www-data /mnt/ncdata/.ocdata
chown -R www-data:www-data /mnt/ncdata
chmod -R 750 /mnt/ncdata
chown -R www-data:www-data /var/www/nextcloud

Yes i used -R before. Just not the /.ocdata part.

I don’t know if it’s useful in your case, but try this when you are in your nextcloud server directorie :
sudo -u www-data php occ maintenance:repair