Need help locating the install directory so I can run occ files:scan


Nextcloud AIO v9.1.0
Completely updated.

  1. I had bank statement in a sub folder of my Linux Mint client; I downloaded them several months ago. I don’t go to them often. Today I needed them and they are all gone.

In my 2 years with NC my wife and I have experienced this type of issue a few times and my search results didn’t come up with anything useful.

I’ve only used occ command once and it worked. That was over 1 year ago.

Now I am trying to run
occ files:scan or
sudo -u www-data php /var/www/nextcloud/occ files:scan
in hopes that some of these missing files are still in bcdata.

I have spent the last 4 hours trying to find the install directory and trying to figure out why I am getting the error php command not found.

I am at the end of my rope, someone please help


You need files-scan (dokumentation) to re-read your Nextcloud data. That is only useful if you copy manual files to Nextcloud and Nextcloud does not know them. By the way, you shouldn’t do that.

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

You execute the command with root. Because the webserver/Nextcloud users (mostly on Debian and Ubuntu) uses the user www-data you must use sudo -u www-data.

occ is a php command so yo must use the php cli interpreter. Mostly you find php directly so you do not need use the path.

for occ you need the path because www-data has it not directly in the path. you can find it e.g. with:

find / -name occ

The search takes a long time. If you know approximately where your web server data is located, you can restrict the path.

find /var/www -name occ)

Full command:

sudo -u www-data php /path/to/occ files:scan --all7

With Nextcloud AIO you use Docker. Then the command differs. Maybe something like that

sudo docker exec -it --user www-data nextcloud-aio-nextcloud php /var/www/html/occ files:scan --all

Hey devnull thanks for the help.

I used find / -name occ and found refeence to a old txt file I made call occ. Read that. Then ith the last part I was able to complete the command.

My notes say:
basic command to run occ commands
sudo docker exec --user www-data -it nextcloud-aio-nextcloud php (command goes here)

I entered: sudo docker exec --user www-data -it nextcloud-aio-nextcloud php /var/www/html/occ files:scan --all
and it is running.

Thanks again I really appreciate it.
Problem with Linux (or me maybe) is that there is so much to learn as you go it’s easy to forget the earlier stuff if you only use it once.
Still better than Windows though

To expand on my thought about missing files~

It makes no sense to me that NC would delete files from my client folder if I didn’t manually delete them.

My current theory is what if the NC indexes got corrupted and thinks I delete those files so it removed them from my client but they still remain in the NCData folder. That’s why I am trying this command.
Now my thought is "Hmm, these files are encrypted! IF my theory is correct and I do the rescan, will it put those files back in the index correctly or will they show up as encrypted when I try to open them?
We shall see.

For future reference, how to run occ commands within AIO is documented here.

Thanks I just put that in My nextcloud favorites.

My scan is complete and based on the results I think there was no problem with indexes since New = 0
Updated = 46423. Not sure what that means exatcly.
Removed = 41764. I don’t believe i deleted 41,000 files/folders so this seems like a red flag to me.
I checked the Web UI in Files and the statements that disappeared (2023 sub folder and individual 2024 files) have not reappeared.

Here is my output:

ncadmin@nextcloud:~$ sudo docker exec --user www-data -it nextcloud-aio-nextcloud php /var/www/html/occ files:scan --all
Starting scan for user 1 out of 3 (admin)
Starting scan for user 2 out of 3 (wife)
Starting scan for user 3 out of 3 (mike)
| Folders | Files  | New | Updated | Removed | Errors | Elapsed time |
| 185740  | 159657 | 0   | 46423   | 41764   | 0      | 00:27:48     |

Hi @mstrauss22

I see that you found the way how to invoke occ in AIO. Great!
You may want to have a more explanative and intuitive usage interface for occ. There exists a wrapper for occ that makes the work extremely easy. It is designed to work not only with barremetal installations but with AIO Installations too (no Docker rootless). I am prety sure that you will love it. You could give it a try: → nc-occ ←
It must be installed on the host, not in a Docker image, and is completely independent of any AIO environment settings.

I hope you like nc-occ

Much and good luck,