How to copy files to specific user in new installation?

Greetings,

rather a question but an issue.

After several unsolvable bugs and problems with my Nextcloud and ageing hardware, I am transferring to a new server. I have been thinking to use the option to import a backup during the new installation.

Yet I am unsure if that would import the same old problems again. Can that happen?

I am thinking to set up the new installation from scratch, setting up the users, user-groups and group-folders using the same names, copying the old files to the files folder and having Nextcloud re-scan the files.
Will that work? And are meta-information like internal file IDs, old versions, shares and stuff stored inside the folders or just the database? The loss of database-only information is acceptable as there is nothing irreplaceable yet, just things that mean extra work to recreate.

Or is there another way to import the old data without importing old bugs again?

The Basics

  • Nextcloud Server version:
    • 30.0.9
  • Operating system and version:
    • Windows 10 Professional - latest version (old)
    • Linux Mint 22.1 (new)
  • Web server and version:
    • Whatever is included in the latest AIO
  • Reverse proxy and version:
    • None
  • PHP version:
    • 8.3.19
  • Installation method
    • AIO v10.12.0
  • Are you using CloudfIare, mod_security, or similar?
    • No

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.


:lock: 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.


:arrows_counterclockwise: 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.)

: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.

Thank you very much! I tried that and it worked, mostly.

However, changing the owner to www-data:www-data made the folders and files inaccessible to the cloud. I had to change the owner to the main user e.g. grom:grom to make them accessible at all and to make them scan-able I had to change the permissions to 777. Setting the owner to 33:0 as described elsewhere also didn’t work.

Something seems to be messed with user rights. I did not change anything in that regard that I am aware of and I used the standard installation besides using a folder on a different drive as datadir with --env NEXTCLOUD_DATADIR="/media/grom/data/NC-Folder"

I am quite sure that nothing should have 777 permissions for longer than necessary so I do not think this should be left like that