Skip to content
Boris Rybalkin edited this page Aug 17, 2026 · 57 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.

Step through the majors that are still on the store, one at a time. Connect with SSH and run:

snap refresh nextcloud --revision=996

Wait for it to finish before going further. The web page shows "Nextcloud is upgrading" while the database migration runs, and

snap run nextcloud.repair-status

reports every step and any error. When it reports "done":true with no errors, continue:

snap refresh nextcloud

Revisions currently on the store:

revisionNextcloud
96832
99633
101134

Only the most recent revisions are kept; older ones are removed from the store. If your device is older than the oldest revision listed above there is no upgrade path left through the store - back up your data, remove and reinstall the app, then restore.

Clone this wiki locally