Skip to content

Nextcloud

Boris Rybalkin edited this page Aug 17, 2026 · 58 revisions

Command line tool (occ)

Connect to your device using SSH then run

snap run nextcloud.occ

Maintenance mode

Usually if upgrade fails because of apps Nextcloud may be left in a maintenance mode. The way out is to identify which apps are failing to upgrade and sisable them.

Here is the example for passwords app, apps will be different in your case:

snap run nextcloud.occ app:disable passwords
snap run nextcloud.occ maintenance:repair
snap run nextcloud.occ upgrade
snap run nextcloud.occ maintenance:mode --off

Preview generator

Install the app https://apps.nextcloud.com/apps/previewgenerator

snap run nextcloud.occ preview:generate-all -vvv

Large existing file collections

Use Nextcloud Client to sync your local files to Nextcloud device, it may take some time. You may want to attach a disk with existing files, make sure they are in the right directory: /nextcloud/[user]/files Then Attach it to Syncloud device and activate in storage settings. Another way is to copy files to device into /data/nextcloud/[user]/files

Fix permissions

sudo chown -R nextcloud:nextcloud /data/nextcloud

File scan

Scan files to Nextcloud by running this command on the device:

snap run nextcloud.occ files:scan --all

Trash cleanup

This will permanently remove all deleted files. It is also a workaround for Trash problems when Nextcloud is installed over existing deleted files in user storage directory.

snap run nextcloud.occ trashbin:cleanup --all-users

Database

To enter a database shell use the folowing command:

snap run nextcloud.psql

Export Calendars/Contacts

cd /tmp
git clone https://codeberg.org/BernieO/calcardbackup.git
cd calcardbackup
mkdir backup
sudo chown -R nextcloud:nextcloud .
sudo -u nextcloud PATH="${PATH}:/snap/bin" ./calcardbackup /var/snap/nextcloud/current/nextcloud -p -o backup

Fix admin rights

Check

snap run nextcloud.psql -c "select * from oc_ldap_group_mapping"

Show groups:

snap run nextcloud.occ group:list

Make all admins

snap run nextcloud.psql -c "update oc_ldap_group_mapping set owncloud_name = 'admin'"

Set phone region

snap run nextcloud.occ config:system:set default_phone_region --value="GB"

With two letter code (Alpha 2) from here: Country codes

Cannot upgrade from UI

Nextcloud only allows one major version step at a time. If your device has been offline for a while it may be several majors behind, and a single refresh would try to skip versions.

Check which version you are on:

snap run nextcloud.occ status

Then run the commands below starting with the version next to your current one and continue to the end of the list. Connect with SSH to run them.

Version 32

snap refresh nextcloud --revision=968

Version 33

snap refresh nextcloud --revision=996

Version 34

snap refresh nextcloud --revision=1011

Latest

snap refresh nextcloud

Wait for each step to finish before running the next one. While the database migration runs the web page shows "Nextcloud is upgrading", and this reports every step and any error:

snap run nextcloud.repair-status

It is done when the output ends with "done":true and no step has an error.

Only the most recent revisions are kept on the store, so versions older than the first one listed above are no longer available. If your device is older than that there is no upgrade path left through the store - back up your data, remove and reinstall the app, then restore.

Clone this wiki locally