Permissions issue after hard drive change "Temporary directory is not present or writable"

Hello,

I want to change my hard drive where NextcloudPi is installed. After copying data on the new drive, I wanted to run nc-fix-permissions but here are the errors I have:

{"reqId":"n8ZxSeiTpEmk3WUtZdPC","level":2,"time":"2022-10-04T16:21:12+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/NewDrive/ncdata/tmp is not present or writable","userAgent":"--","version":"24.0.5.1","data":[]}
Running nc-fix-permissions
fixing permissions in /media/NewDrive/ncdata... chown: impossible d'accéder à '/media/NewDrive/ncdata/\*/files': Aucun fichier ou dossier de ce type
chmod: impossible d'accéder à '/media/NewDrive/ncdata/*/files': Aucun fichier ou dossier de ce type
done
Done. Press any key...

Here are the steps I followed to be in this situation.

I have the two disks mounted at something like /media/OldDrive and /media/NewDrive

I copied data using rsync -avz /media/OldDrive/ncdata /media/NewDrive/ncdata

I replaced the OldDrive by the NewDrive in the configuration file for the following directories:

  • datadir
  • tempdirectory
  • logfile

I wanted to run nc-fix-permissions but when trying to do so, I got some errors:

  • .ocdata file missing; I think I fixed this, I do not see it anymore
  • permissions errors

I tried to copy the permissions from /media/OldDrive to /media/NewDrive but I still have errors.

Here is the current situation:
ls -al /media/OldDrive

drwxr-xr-x 1 root     root        468 27 août  03:48 .
drwxr-xr-x 4 root     root       4096  2 oct.  15:01 ..
drwxrwx--- 1 www-data www-data    244 27 août  06:42 ncdata
drwxr-xr-x 1 root     root        392  1 oct.  03:00 ncp-backups
drwxr-xr-x 1 root     root       2314  3 oct.  20:17 ncp-snapshots

sudo ls -al /media/NewDrive

drwxrwx--- 1 root     root       12  2 oct.  16:18 .
drwxr-xr-x 4 root     root     4096  2 oct.  15:01 ..
drwxrwx--- 1 www-data www-data   52  3 oct.  21:35 ncdata

I do not know how permissions work in Linux so I am lost. I see there is a difference in the first line but I do not know how to copy and paste the permissions for this “.”. I am not even sure my problem comes from this.
Could someone help me how to fix this please?

Looks like there is a typo in the nc-fix-permissions.sh possibly?


Edit: never mind, this is not a typo, but rather caused from the manual moving of files without including all the files


The permissions should be set recursively, so for all the sub-directories and files as well, unless I’m mistaken. I don’t know, could you try and see if this works? Or maybe without the /files perhaps?

chown -R www-data:www-data /media/NewDrive/ncdata/files

chmod -R u+rw /media/NewDrive/ncdata/files

chown -R www-data:www-data /media/NewDrive/ncdata/files
Gives a permission issue

Sudo chown -R www-data:www-data /media/NewDrive/ncdata/files
Gives this error:
impossible d’accéder à ‘/media/NewDrive/ncdata/files’: Aucun fichier ou dossier de ce type

Which means “Impossible to access to the directory, no file or directory of this type.”

This is the same error than when I do nc-fix-permissions

-------- Message d’origine --------

Yes, it’s saying the directory doesn’t exist :slight_smile: it seems you didn’t move your files recursively from the old location to the new, you need to check that

Edit
Or well, you did with the -a flag, but also made it into an archive, not the same hierarchy as before, if you instead use -r the hierarchy should remain the same, but please check their docs/manual for which flags you need :pray: man rsync

Finally I managed to get everything working again.

My rsync command was not good as it created one subfolder “ncdata” more than needed. I had /media/NewDrive/ncdata/ncdata while my datadir was /media/NewDrive/ncdata
This was the reason why the files were not found.

I saw on another thread that the use of subvolumes could be preferable instead of directories and discovered that there is the nc-datadir command function that could do what I wanted as standard. So I deleted everything I copied on my new drive and used that function instead.
I then had a permission issue but I fixed it manually with this Linux File Permissions and Ownership Explained with Examples

nc-datadir created one more subfolder as I mistakenly did with rsync, I now have /media/NewDrive/ncdata/data but I can live with that. Did not know what to input in the command, with or without ncadata

Anyway thanks a lot for your time.