Pre-loading folder on NAS and then sync

I installed Nextcloud version 14.0.3 (server) on my Synology NAS in a docker container and Nextcloud client 2.3.3 (build 84) on my MAC. Works great.

I have a folder which contains my programming projects. It contains a lot of very small files and I notice Nextcloud takes a long time to sync these. I notice the same with syncing that folder to Dropbox or Google Drive but would expect Nextcloud to be quicker given it’s on my 1Gbps home network. Likely sync services are struggling with these millions of very small objects. In any case, syncing 7GB (600.000 small files) takes already multiple weeks now and still only 20% done. Again, on Google Drive it takes even longer so not blaming Nextcloud for it.

As the folder is on my PC, I could also precopy the folder to my NAS and then setup my Nextcloud client to sync the folder. In such case, the files are already copied by myself and my thinking process is that the syncing would go faster. Would that work with Nextcloud or can it only work if Nextcloud copies the file (and not me in a manual fashion)?

If I understand it correctly, you have huge folder on your PC and want to put it to NC (that is running under your NAS).
You have few ways:

  1. Use webdav interface and copy files from PC into NC (not very fast)
  2. Use NC Client to sync PC folder into NC (I have had better experience with this)
  3. Just copy your huge folder by your hand into .../data/USER_NAME/files/YourHugeFolder.
    Set correct ownership (user of your NC, w.g. www-data).
    Run command to re-scan folder under your NC user. I have no Synology, but command for linux will be like this:
    sudo -u www-data php occ files:scan --path="USER_NAME/files/YourHugeFolder"
  4. If folder is already on the NAS, just added your huge folder from NAS to NC as external storage and ether go into it via web to force NC to read it, or run same command from above to force NC to read this folder.
    P.S. this simple script is in my daily cron and will re-sync external shares only.

I believe number 3 and 4 will be the fastest one.

1 Like

Hi,

Many thanks for your extensive answer. I will be using option 3. Option 4 is not possible for me as the files are not yet on the NAS itself. They are on my local MAC and I was using the client to sync them. Unfortunately that goes so slow that it’s unmanageable. Therefore I will copy the files over manually and then scan the folder

Hi @gas85 I tried option 3. The files are now copied over. Have an issue though.

You mention to use

sudo -u www-data php occ files:scan --path=“USER_NAME/files/YourHugeFolder”

I have Nextcloud running in a Docker container. When I login to the docker container as root and execute the command it says:

bash: sudo: command not found

I checked what distribution this Docker container is running and it appears to be Debian 9. So I tried to install ‘sudo’. I get however

E: Unable to locate package sudo

Then when I try to switch user to www-data (with the idea to just run the php occ command from within that user), I get:

root@nextcloud1:~# su www-data
This account is currently not available.

So I am a bit stuck on what to do next to solve this issue? I definitely need to scan the folder as the files are copid over and available but they are not shown int he Nextcloud user interface.

I have no docker, but try this one:

Seems it should be something like:

docker exec -it <container_id_or_name> php /path/to/NC/occ files:scan --path=“USER_NAME/files/YourHugeFolder”

root@Synology-NAS:~# docker exec -it 414e php /var/www/html/occ files:scan --path=“/volume1/docker/nextcloud/data/nextcloud/files/Dropbox”
Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: www-data
Try adding 'sudo -u www-data ’ to the beginning of the command (without the single quotes)

When I do this I get another error:

root@Synology-NAS:~# docker exec -it 414e sudo -u www-data php /var/www/html/occ files:scan --path=“/volume1/docker/nextcloud/data/nextcloud/files/Dropbox”
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused “exec: "sudo": executable file not found in $PATH”

Can I run the rescan via de UI instead of the CLI? That would be the easiest I presume.

Try to put relative path in --path in your case it could be:

docker exec -it 414e php /var/www/html/occ files:scan --path="nextcloud/files/Dropbox"

where nexctcloud - USER Name

files should be there

Dropbox - is your folder

Check:
Your user/login Name is “nextcloud”?
Is this path is also listed in config.php like this: 'datadirectory' => '/volume1/docker/nextcloud/data',

Tried with relative path, not working either

> root@Synology-NAS:~# docker exec -it 414e php /var/www/html/occ files:scan --path="nextcloud/data/nextcloud/files/Dropbox"
> Console has to be executed with the user that owns the file config/config.php
> Current user: root
> Owner of config.php: www-data
> Try adding 'sudo -u www-data ' to the beginning of the command (without the single quotes)

Yes, nextCloud is my username.

The path listed in config.php is:

'datadirectory' => '/var/www/html/data',

But given this is running on Docker their is a mapping (link) between:

/var/www/html and docker/nextcloud.

So essentially the /var/www/html/data directory maps to /volume1/docker/nextcloud/data

Reason for this mappign is that all files get directly written on a volume in my NAS and not in the Docker filesystem somewhere. See screenshot below

Ok, first of all

you do not need put nextcloud/data here. Only nextcloud/files/Dropbox. Path should be relative to data folder.

Second is - check who owns the config.php under config/config.php - this is your docker/NC user.
You have to run it with user that owns NC or config.php.

Here is listed that you need to use -u or --user option:

try to execute:

docker exec -u DOCKER_USER -it 414e php /var/www/html/occ files:scan --path="nextcloud/files/Dropbox"

If user www-data owns config.php, execute following command:

docker exec -u www-data -it 414e php /var/www/html/occ files:scan --path="nextcloud/files/Dropbox"

or

docker exec --user www-data -it 414e php /var/www/html/occ files:scan --path="nextcloud/files/Dropbox"

You can achieve it by option number 4:

Hope, it helps you.

Thanks @gar85. The command

docker exec -u www-data -it 414e php /var/www/html/occ files:scan --path="nextcloud/files/Dropbox"

is working indeed. It seems indeed the relative path is important here.

It’s now already scanning for more than 12 hours so I hope all will work in the end.

1 Like