Skip to main content

Run OCC Maintenance Commands in Nextcloud AIO

🎯 Purpose

To perform maintenance, repairs, and database optimizations on your Nextcloud AIO instance using the built-in occ command-line interface.

📍 Requirements

  • Access to the server where Nextcloud AIO is deployed
  • Docker installed and running
  • Container name (usually nextcloud-aio-nextcloud)

🛠 Step-by-Step Instructions

1. SSH Into Your Server

ssh mslsadmin@cloud

2. Enter the Nextcloud Container

docker exec -it nextcloud-aio-nextcloud bash

Note: You'll now be inside the container as root. All occ commands must run as the www-data user.

3. Run Standard Repair

sudo -u www-data php occ maintenance:repair

This command performs:

  • Missing index creation
  • Mimetype corrections
  • Database constraints
  • App cleanup routines

4. Run Full Repairs with Expensive Operations (Optional)

sudo -u www-data php occ maintenance:repair --include-expensive

This version also:

  • Migrates mimetypes for large datasets
  • May take several minutes to complete

🔁 Other Common OCC Maintenance Tasks

Disable Maintenance Mode

sudo -u www-data php occ maintenance:mode --off

Enable Maintenance Mode

sudo -u www-data php occ maintenance:mode --on

Clear File Cache (Use with caution)

sudo -u www-data php occ files:cleanup

✅ After Running

  • Exit the container:
    exit
  • Refresh Settings > Overview in your Nextcloud web UI
  • Warnings should disappear and system health will improve

Maintained by MSLS Partners LLC — Internal Nextcloud Guide