NextCloud Adding Files to External Storages

NethServer Version: 7.3
Module: NextCloud
In NextCloud, files in external storages, are only backed up/versions created if they are edited in the web interface. In the NextCloud manual, it states the following if you want to create a version if the file is edited or overwritten outside of NC on the external storage.

You might need to setup a cron job that runs sudo -u www-data php occ files:scan --all (or replace “–all” with the user name, see also Using the occ Command) to trigger a rescan of the user’s files periodically (for example every 15 minutes), which includes the mounted external storage.

On NS, I have no www-data user, do I need to create the user, or run as a different user?
What user is NC running as on NS?
Also, I am unsure if I just add the command to the users crontab, or if I need to change the cron type in Admin from Ajax (which was set by default), to Cron? This is a little confusing.

On CentOS the user for the Apache web server is apache instead of www-data

External storage will be scanned regularly by Nextcloud: with ajax the preset jobs will be run on loading a page, with webcron the scheluding will be handled by an external service. The prefered method is system cron.

If that’s not enough and files on external storage are not shown (or take a lot of time to be shown) within nextcloud, you can force a rescan either manually or by setting a system cron job.

About the cronjob you can create it under apache’s user crontab. Or in root’s crontab but setting the task to be run by the apache user.

Ok, I can run the command, but I can still get no versions on external storage.
Has anyone successfully got versions to save on an external storage?
I have an external CIFS storage location, which I can successfully see in NC, and I can see any changes that are made on files edited not in NC, and I get versions if the file is edited in NC.
But, if I edit the file not in NC, I then run the command,

sudo -u apache php occ files:scan --all

which successfully scans files for all users, which is supposed to include external shares, but no versions on external shares.

File versioning works when files are used from nextcloud web interface, the nexcloud app, or from a nextcloud webdav mount, otherwise it has no way to track file changes.

IIRC files versions can be added (forced) by an external script using nextcloud’s API, but never tried.

1 Like

Yes, I get versions if the external storage file is edited in the web interface, but the NextCloud manual states the following (and I am editing a file in the root of the external share, not deep within hierarchy)

Adding Files to External Storages
We recommend configuring the background job Webcron or Cron (see Defining Background Jobs) to enable Nextcloud to automatically detect files added to your external storages.

Nextcloud may not always be able to find out what has been changed remotely (files changed without going through Nextcloud), especially when it’s very deep in the folder hierarchy of the external storage.

You might need to setup a cron job that runs sudo -u www-data php occ files:scan --all (or replace “–all” with the user name, see also Using the occ Command) to trigger a rescan of the user’s files periodically (for example every 15 minutes), which includes the mounted external storage.

I use webcron(easycron.com) which manages multiple sites cronjobs and provides feedback and reporting.