External Storage Scan missing files

Support intro

Hello Nextcloud community,

I am currently facing an issue with my Nextcloud setup, and I am seeking a fix for it

The problem is related to external storage.

I have an external storage mounted at “/mnt/nextcloud-data”, and new files created outside Nextcloud in this location are not appearing in the Nextcloud interface.

Initially, I had the default AJAX setting for file scanning, but I saw in the documentation to switched to cron for external storage.
Unfortunately, with cron, the scanning process doesn’t seem to work correctly. It doesn’t report a job run but a warning message saying that something might be wrong.
The Setup is completely new I tried Nextcloud 28.0.1 and 27.1.5.1, I switched to Nextcloud 27 because there was an Error about external storage which I found on GitHub too. I also tried Nextcloud AIO 28 before, it had the same problem but at least cron worked by default there.
It’s fixed in 28.0.2, I plan to upgrade when it’s released

I run nextcloud with Docker Compose on Linux
my docker compose:

version: '2'
services:
  nextcloud:
    image: nextcloud:27
    volumes:
      - ${WEBAPP_STORAGE_HOME}/site/nextcloud:/var/www/html
      - ${WEBAPP_STORAGE_HOME}/site/ca:/etc/ssl/azure
      - nextcloud-data:/mnt/nextcloud-data
    ports:
      - 8000:80
    restart: always

  nextcloud-cron:
    image: nextcloud:27
    container_name: nextcloud-cron
    restart: unless-stopped
    volumes:
      - ${WEBAPP_STORAGE_HOME}/site/nextcloud:/var/www/html
      - ${WEBAPP_STORAGE_HOME}/site/ca:/etc/ssl/azure
      - nextcloud-data:/mnt/nextcloud-data
    entrypoint: /cron.sh
    depends_on:
      - nextcloud

Steps to replicate it:

  1. add “/mnt/nextcloud-data” as external storage with Check for changes enabled
  2. create a File outside Nextcloud on the external storage
  3. look for file inside nextcloud

There are no Entries about this in the Logs

Could it be that the whole scan process could be broken? Ajax jobs finish but don’t show new files but cron and webcron jobs don’t finish at all

I have an external storage mounted at “/mnt/nextcloud-data”, and new files created outside Nextcloud in this location are not appearing in the Nextcloud interface.

Outside of Nextcloud, but still inside your Nextcloud container, correct? Or are you trying to add/create files outside of the container?

  1. add “/mnt/nextcloud-data” as external storage with Check for changes enabled
  2. create a File outside Nextcloud on the external storage
  3. look for file inside nextcloud

So you’re writing directly to a Docker internally managed volume from your underlying host? Or is the file you’re creating in step 2 something you’re doing within one of the containers?

- nextcloud-data:/mnt/nextcloud-data

This creates a mount point called /mnt/nextcloud-data within your Docker two containers, but nextcloud-data is an internally managed volume in Docker (it’ll likely be located in /var/lib/docker/volumes/<something>.

I assume this is not also configured as your datadirectory in your config.php, correct?

Apologies for confirming, but you didn’t provide your actual Nextcloud config so working with what you posted. :slight_smile:

Unfortunately, with cron, the scanning process doesn’t seem to work correctly. It doesn’t report a job run but a warning message saying that something might be wrong.

What’s the message?

The bind mounted volume in the compose is a samba share mounted in the docker host, the File was created outside of the container but it looks same as when created in the container, it appears for www-data and has correct permissions.

My config.php is completely stock, I don’t need the primary storage and added the directory with the external storage app as a local storage

The Message about the cron job was last job ran x minutes ago. something might be wrong. I tried cron with the cron.sh entrypoint docker and then changed the setting from AJAX to Cron. Maybe the setting doesn’t work with the seperate cron container

Update:
I tried some more things, I built a docker Image using the example cron and samba dockerfiles from the nextcloud github and reinstalled everything again and it’s now using cron correctly. (I also did this on my old Nextcloud AIO V28 Instance and on Nextclouv V27 and V28)

This time I mounted the drive through samba in the external storage app instead of mounting it through docker:

Same Issue still appears but it’s odd, 5-10 Minutes everything works as expected. If you add a folder or file outside nextcloud to the samba drive, nextcloud finds it when you navigate to it.

But then it breaks and doesn’t show any new created files anymore, sometimes it shows them when they are in the root directory of the samba volume but only rarely.

Nextcloud Settings says Last Cron Job ran x seconds ago, everything ok there.
But I tried triggerring a manual scan with occ files:scan --all and it worked, the output of the command didn’t say it found new files but the new files appearred after running the command.

The only way I can think of to fix this is scheduling that command but it’s not very fast and kind of janky, scanning 20 folders and 20 empty txt files for 3 Users took 1 Minute but I saw people write scripts for that purpose.