How to copy files to specific user in new installation?

Adding Files to a Specific User in Nextcloud AIO

This guide is based on my personal notes and hands-on experience with Nextcloud — particularly during migrations from an old server to a new Nextcloud AIO instance.

It also comes from situations where I had persistent issues syncing large files via the Nextcloud desktop client. As a workaround, I looked for alternative ways to transfer files directly to the server and ensure they would be properly recognized by Nextcloud without relying on the sync client.


:compass: What You Should Know Before You Start

  • The user account (e.g., john) must already exist in Nextcloud.
  • It doesn’t matter how you copy the files to the server — rsync, scp, USB, shared folder, or any other method is fine.
  • What does matter is where the files are placed and what permissions they have.

:card_index_dividers: 1. Copy Files into the User’s files/ Directory

Place the files or folders inside the following path:

/var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data/john/files/

:warning: Do not replace the files/ folder itself. Only copy content into it.


:locked: 2. Set Ownership and Permissions

To make sure the Nextcloud web server (www-data) can properly read and manage the files, set ownership and permissions as follows.

Use sudo if you’re not logged in as root:

Set ownership:

sudo chown -R www-data:www-data /var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data/john/files/

Set permissions for directories:

sudo find /var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data/john/files/ -type d -exec chmod 750 {} \;

Set permissions for files:

sudo find /var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data/john/files/ -type f -exec chmod 640 {} \;

These permissions ensure full access for the Nextcloud service while keeping the files private from other system users.


:counterclockwise_arrows_button: 3. Trigger a Full File Scan

To make Nextcloud recognize the newly added files, you need to run a scan.

:white_check_mark: Recommended: Full scan including app-specific data

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

This ensures everything is scanned, including:

  • All user folders
  • Group folders
  • External storage
  • App-specific data (e.g., Notes, Deck, Talk, etc.)

:light_bulb: Optional: Scan a specific user only

If you only copied files to a single user and want to speed things up:

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

:white_check_mark: Summary

  • Copy your files into /.../_data/username/files/
  • Set ownership to www-data and permissions: 750 for directories, 640 for files
  • Run a full scan to make the files visible — preferably using files:scan-app-data && files:scan --all

By following these steps, the files will show up immediately in the user’s Nextcloud interface upon login — even when large files or sync limitations make using the desktop client impractical.