
Background
I had installed NextCloud on my server and used it with my family, so it held every user’s pictures and videos.
One day my server went haywire and I saved time by simply reinstalling everything from scratch.
Anyway, I reinstalled NextCloud (I had made a backup, I’m not crazy :p).
Problem
When you put folders (photos, videos, etc…) into the users’ files folder without going through NextCloud (using FTP for example), NextCloud doesn’t pick them up and doesn’t display them.
On top of that, it doesn’t allow two folders with the same name (which makes sense), so this can cause problems: even though users can’t see the folders, NextCloud knows they’re there.
Solution
First step: if you had a user “Bob”, for example, create him from the admin account.
That creates a folder with his name in the directory that holds the /data data you chose when you started the container.
Example:
- /ton/chemin/data:/data
Now give him the folders/files that belong to him.
Indeed, NextCloud can’t see them but it knows they’re there, so all that’s left is to refresh the database so they become visible.
Finding the path of the NextCloud occ file
We’ll need to know its location later. According to the official docs: https://docs.nextcloud.com/server/latest/admin_manual/occ_command.html it’s located in /var/www/nextcloud. But in my case it wasn’t there, so the following command lets you find it. Make sure to replace nom_de_ton_container_nextcloud with the name of your container.
docker exec -it nom_de_ton_container_nextcloud find / -name occ
Don’t worry about the “Permission denied” errors, the paths show up at the very bottom.
Personally, I use /app/www/public/occ

Connecting to the Docker container
In the command, the -u 911 lets you connect as user 911, which is what the logs asked me to do in order to run the occ command.
Make sure to replace nom_de_ton_container_nextcloud with the name of your container.
docker exec -u 911 -it nom_de_ton_container_nextcloud /bin/bash
Refreshing the NextCloud database
NextCloud provides the occ file for this kind of case, you just have to run the following command:
Of course, replace the path /app/www/public/occ with your own path.
php /app/www/public/occ files:scan --all
This command refreshes the database based on the files present for each user.
