Tried to migrate Nextcloud data, messed up permissions on /var | J'ai essayé de migrer les données Nextcloud, j'ai changé les permissions de /var

:uk:

My YunoHost server

Hardware: Old Computer at home
YunoHost version: 11.2.9.1
I have access to my server : Through SSH, the webadmin and direct access via keyboard and screen
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : yes, I tried to migrate Nextcloud data on a mounted HDD using this page

Hello ! :wave:

I will try to explain everything that happened since the first issue I encountered.

I recently tried to migrate all my Nextcloud data from the main SSD (where YH is installed) to my HDD that is already mounted to my system and host other apps data (like Jellyfin). I used this page to help me perform the migration but I encountered unexpected issues. I logged in SSH as the administrator user of YH, and tried to execute all the commands as stated in the documentation. However, after copying all the data to the HDD and changing the config.php to specify the new data directory path, when I had to scan the new directory by first going to the nextcloud directory with command :

cd /var/www/nextcloud

I got the error :

No such file or directory

So I thought it may be some permission issue, because the /var/www/nextcloud directory doesn’t belong to the administrator and doesn’t have read permissions. So I thought that maybe the command was meant to be run as root. So I run the same command as root, I manage to get to the directory, and when I executed the next command :

sudo -u nextcloud php8.1 --define apc.enable_cli=1 files:scan --all

This time I got the error :

Could not open input file: files:scan

I searched about this error and didn’t find anything relevant to my case.

Now that’s where the foolish part begins. I assumed it was another permissions issue, so I decided to do something very unintelligent : give all permissions for /var and everything inside to the administrator, instead of root. Yes I realize that is not the smartest thing I’ve done, but I did it. So I recursively applied a chown and a chmod command to give the admin full rights on the /var folder.

And from then, other worse issues appeared. Suddenly I lost SSH access with every YH user (root still works). Also, I don’t know if it’s always been the case and/or if it’s normal, but YH users are displayed as numbers, and not their name, when showing ownership of folders and files with ls -l command. Aside from that, basically most of my apps have now stopped working displaying errors saying that their access to var/www/<app-name> is denied (obviously).

So my question is, is there a way to repair my mistake and make the /var folder back to its original permissions settings aside from a complete reinstall ?

Thank you very much for reading.


:fr:

Mon serveur YunoHost

Matériel: Vieux PC à la maison
Version de YunoHost: 11.2.9.1
J’ai accès à mon serveur : Via SSH, l’interface web d’admin et accès direct avec clavier/écran
Vous êtes dans un contexte particulier ou vous avez effectué des réglages particuliers sur votre instance YunoHost : : oui, j’ai essayé de migrer mes données Nextcloud sur un disque dur monté en utilisant cette page

Bonjour !

Je vais essayer d’expliquer tout ce qui s’est passé depuis le premier problème que j’ai rencontré.

J’ai récemment essayé de migrer toutes mes données Nextcloud de mon SSD principal (où YH est installé) vers mon disque dur qui est déjà monté sur mon PC et qui héberge les données d’autres applications (comme Jellyfin). J’ai utilisé [cette page] (Nextcloud | Yunohost Documentation) pour m’aider à effectuer la migration mais j’ai rencontré quelques problèmes. Je me suis connecté en SSH en tant que l’utilisateur administrateur de YH, et j’ai essayé d’exécuter toutes les commandes indiquées dans la documentation. Cependant, après avoir copié toutes les données sur le disque dur et modifié le fichier config.php pour spécifier le chemin du nouveau dossier, lorsque j’ai dû scanner le nouveau répertoire en allant d’abord dans le répertoire nextcloud avec la commande :

cd /var/www/nextcloud

j’ai obtenu l’erreur suivante :

No such file or directory

J’ai donc pensé qu’il pouvait s’agir d’un problème de permission, car le répertoire /var/www/nextcloud n’appartient pas à l’administrateur et n’a pas les permissions de lecture. J’ai donc supposé que la commande devait être exécutée en tant que root. J’ai donc lancé la même commande mais en tant que root, j’ai réussi à accéder au dossier, et lorsque j’ai exécuté la commande suivante pour scanner le nouveau dossier des données:

sudo -u nextcloud php8.1 --define apc.enable_cli=1 files:scan --all

Cette fois-ci, j’ai obtenu l’erreur suivante :

Could not open input file: files:scan

J’ai fait des recherches sur cette erreur et je n’ai rien trouvé de pertinent pour mon cas.

C’est là que la partie stupide commence. J’ai supposé qu’il s’agissait là d’un autre problème de permissions, et j’ai donc décidé de faire quelque chose de peu intelligent: donner toutes les permissions pour /var et tout ce qui s’y trouve à l’administrateur, au lieu de root. Oui, je réalise que ce n’est pas la chose la plus intelligente que j’ai faite, mais je l’ai fait. J’ai donc appliqué récursivement une commande chown et une commande chmod pour donner à l’administrateur tous les droits sur le dossier /var.

Et à partir de là, d’autres problèmes plus graves sont apparus. J’ai soudainement perdu l’accès SSH pour tous les utilisateurs de YH (root fonctionne toujours). De plus, la plupart de mes applications ont maintenant cessé de fonctionner en affichant des erreurs disant que leur accès à var/www/<nom-de-l'application> est refusé (évidemment).

Ma question est donc la suivante : existe-t-il un moyen de réparer mon erreur et rétablir les permissions du dossier /var à ses paramètres d’origine mis à part d’une réinstallation complète ?

Merci beaucoup pour votre lecture et merci d’avance pour votre aide.

cat /etc/passwd

Et

ls -l /var

Pourrais-tu développer ? J’ai du mal à comprendre en quoi cela pourrait résoudre mon problème.

Merci !

Hi fillthevoid,

Welcome to the forums!

Sorry you got stuck for so long :frowning: Did you resolve any of those problems?

Hmmm… On scanning the command line, it seems to miss the actual command (occ is the command line utility that should be called)

Have a look at Nextcloud’s documentation, Using the occ command — Nextcloud latest Administration Manual latest documentation

I think, when you are root in /var/www/nextcloud the line should read

sudo -u nextcloud php8.1 --define apc.enable_cli=1 occ files:scan --all

(notice occ before files:scan)

Good luck!

Hi @wbk !

Thank you for taking the time to answer :slight_smile: Indeed it could be the cause of the issue, I can’t try it right now because I would like to fix the permissions mess on the /var directory.

So far I tried to manually set the permissions of each file and folder inside /var back to how it was before I messed up (not sure if I correctly did it), and now most of the server is working properly again. However there are still some weird things that happen on some apps and during some processes.

Do you have any ideas on how I could reset /var permissions back to its default permissions settings without doing a fresh reinstall ?

Thanks !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.