Copying data to Nextcloud via FTP

Suppose you need to copy data via FTP to Nextcloud.
Configure the FTP server if it is not configured, for example, as I described in the article:
Configuring ProFTPd with virtual users in a file

Create an FTP user that will work on behalf of the user and the www-data (uid 33) group:

sudo ftpasswd --passwd --file=/etc/proftpd/ftpd.passwd --name=test --uid=33 --gid=33 --home=/var/www/nextcloud/data/USER/files/FTP/ --shell=/bin/false

Now if you copy files via FTP, they will not be visible in Nextcloud, if you delete files via FTP, they will remain in Nextcloud, so to update the cache, execute:

cd /var/www/nextcloud
sudo -u www-data php occ files:scan --all

To automatically update the cache, you can make a script:

#!/bin/bash
cd /var/www/nextcloud
sudo -u www-data php occ files:scan --all --no-interaction --quiet

And add it to /etc/crontab (for example, to run hourly):

1 * * * * root /dir/nextcloud_scan.sh

See my articles:
Install Nextcloud in Ubuntu
Using and configuring CRON

Join the Conversation

1 Comment

Leave a Reply

  1. Maybe a tip for large installations. You could limit the path search, if you always upload your files to the ‘FTP’ folder for example.

    Example of the command:

    php occ files:scan –path=”USER/files/FTP”

Discover more from IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading