OCC maintenance

So, Nextcloud works pretty good as just a simple server instance rather than AIO (Premade collection of containers), but there comes a time when some maintenance is required.

On the default install, there are no background maintenance running through cron. We can add some.

Photo and file previews

Generating all the previews for a large photo collection takes many hours. Its not something that you want to be “on demand”.

There is a nextcloud app that can be installed which allows you to schedule/perform the preview generation. Aptly named Preview Generator, it can be found in the list of installable apps.

Details on use can be found in :-

Quick summary of some useful options

# Get logged into your nextcloud container.
docker exec -itu www-data nextcloud-container-name bash

# Pre-generate the previews of photos and files
# This is used to generate ALL previews on recent install/reinstall

./occ preview:generate-all [-vvv] [--workers=WORKERS] [--path=PATH] [user_id]

The ‘vvv’ option switch is for verbose mode on the command line. Clearly not needed for a headless offering

‘workers’ is for number of concurrent operations

“path” allows specific group of files/folders to be operated on. Using “path” overrides the “user_id”. The path starts from the user name. I.e. :-

“[user_id]/files/Documents/….”

Note the process is running as www-data user due to being the owner of all the files.

The above is very time consuming. The preview generator has another option for just running on the files created after its last run. This is used to keep the thumbnails up to date. Its called “pre-generate”

The general advice on the preview command is to run it as a system cron job. I used the code below to achieve this.

#the following command starts the cron editor
crontab -e

#I then added the following line
* */1 * * * docker exec -u www-data nextcloud /var/www/html/occ preview:pre-generate

The is causing the generator to run once an hour. Again under the www-data user.