brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: occ versions:cleanup --path deletes the old versions of one Nextcloud folder

Apps and containers
~/tips/tip-nextcloud-versions-cleanup-path

sudo -E -u www-data php occ versions:cleanup \

Deletes the stored file versions of a user, limited to one folder with --path.

Every time a file changes, Nextcloud can keep the old one as a version. For a folder with big files that change often, those versions pile up quickly. A cleanup of everything is blunt, so I like that you can aim it at one folder.

The command takes one or more user IDs, and --path narrows it to a directory. The path has to include the user ID and files/:

sudo -E -u www-data php occ versions:cleanup \
  --path="/layla/files/Documents" layla

Without --path it deletes the stored versions of the listed users. Without any user it does it for all users, which is the one to be careful with.

Warning: this deletes versions for good. After it runs, nobody can restore an older state of those files from the web interface. I would run it only for a folder where the history has no value, such as a downloads or media folder, and I would check what people actually need first. There is no dry run flag in the manual, so the scope you give is the only safety.

For a softer approach there is versions:expire, which expires versions that exceed the retention period set by versions_retention_obligation in config.php. The docs say it only does something when a custom retention period is configured. With the default auto-expiration it exits and leaves the work to the background job.

As with other newer occ commands, the --path option is in the latest manual, so run occ help versions:cleanup to see whether your version has it.

Further reading: occ files commands, file versions (Nextcloud admin manual)

Going deeper: Guide: link Prowlarr to Sonarr and Radarr once, and stop typing indexers into every app

More Apps and containers tips sudo -E -u www-data php occ user:report sudo -E -u www-data php occ config:system:get trusted_domains sudo -E -u www-data php occ app:update --showonly sudo -E -u www-data php occ background-job:history -s 3 -l 10 immich upload --skip-hash --recursive directory/ All Apps and containers tips (52) All topics

Link