How to speed up initial sync of large folder

Proposed additional step before running occ files:scan

You already mentioned that ownership is fixed to www-data, which is correct.
However, even with correct ownership, inconsistent POSIX permissions on directories or files can still cause Nextcloud to silently skip files during scanning, especially with large datasets.

These steps are not theoretical.
I have them documented in my own migration notes, collected while migrating a Nextcloud server, and I consistently apply them as “steps of certainty” before every large import or re-scan.

Normalize directory permissions

find . -type d -exec chmod 750 {} \;

This ensures:

  • execute permission on directories so Nextcloud can actually traverse them

  • full read/write/execute access for www-data

  • eliminates permission-related skips during recursive scans

Normalize file permissions

find . -type f -exec chmod 640 {} \;

This ensures:

  • all files are readable and writable by the web server

  • avoids unreadable files being silently ignored during indexing or checksum generation

Then run the scan

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

Why this may help in your case

During my own server migration, I observed that:

  • ownership alone was not sufficient

  • mixed or inherited permissions caused some files to be skipped without visible errors

  • scans completed successfully, yet not all files appeared in the UI

Normalizing permissions before scanning has proven to be a reliable safety step to ensure that all files are actually reachable by occ files:scan.


Note: This post was written with the help of an AI assistant as a writing aid only. The opinions, solutions, and technical recommendations are fully based on my personal experience.
More about how and why I use AI to write forum posts:
:right_arrow: Is there limitations to installing Nextcloud via CT template on Proxmox - #4 by vawaver

1 Like