Officially Nextcloud apps cannot be downgraded. If you find a a problem you're supposed to report it to the app maintainer and they'll fix it and publish a new version. But in the real world that can take a long time and reverting back to the old version that worked is a much quicker fix.
I've now seen a few other references for this process for other apps like Calendar and Group Folders. The real-life scenario for me was updating Nextcloud from 26.0.1 to 26.0.2 which helpfully applied all available app updates, including the version 3.2.0 of the Mail client.
It turns out this version doesn't like Dovecot IMAP, at least how I and a few others have it configured (which is pretty standard using an LDAP for user info). While there's currently no fix for this at the time of writing, via the Nextcloud forum Vasyugan shared the approach for reverting the version of mail.
Warning
If the update makes changes to data then a downgrade might not work and could even make things worse. Test before doing this and make sure you have a good backup.
Downgrading all of Nextcloud to a previous version is a very different story and I'd be very surprised if that worked.
Steps:
- Obtain earlier version of app
- Backup Nextcloud
- Disable app
- Rename / Move app folder
- Deploy older version
- Enable App
- Test
Assuming that you have a Test and Live instance of Nextcloud (and if not, add creating a test instance to your to-do list), prove the downgrade process in your Test instance first and then if it fixes the problem repeat it in the Live instance.
Downgrade Process
Obtain earlier version of app
Most apps are obtained from the Nextcloud App Store and this is integrated into Nextcloud itself to make installation simple. Navigate to https://apps.nextcloud.com and then locate the App you want to downgrade. In this example, Mail can be found under the Features Apps, Office & Text or Social & Communication categories.

Scroll down to the Downloads section and click on the All Releases link for your version of Nextcloud.

Then scroll down the list to the version required, in my case 3.1.1. Click the download link to get the installation archive which in this case is mail-3.1.1.tar.gz

Backup Nextcloud
Just in case something really interesting happens now is a good time to take a full backup of your Nextcloud installation. I have a Bacula job for this which runs every night so it only takes a few minutes to trigger the process. If you're running in a VM then an offline snapshot is also an excellent method, but of course that's more of an interruption to users.
At this point you should also warn your users to stop using the affected app for a short while.
Disable app
As an administrator user go to the Settings > Apps to display the list of Apps installed on the server and scroll down to locate the one you want to downgrade.

Click on the Disable button and the app will move to the bottom of the list. The Disable button will change to an Enable button and a remove link might also appear if the app is removable - don't click this unless you also want to remove any data held in Nextcloud.

Rename/Move app folder
Login to the Nextcloud server and navigate to your apps directory. I installed to /srv/nextcloud/www so in my case apps are located under /srv/nextcloud/www/apps. Moving or renaming the app folder means you can easily put it back again if the the downgrade attempt fails.
cd /srv/nextcloud/www/appsmv mail /srv/nextcloud/backup/appDeploy older version
Copy the installation archive to the apps folder and extract it, then set the ownership of all the files to match the rest of Nextcloud which for me is the default apache2 user and group of www-data:www-data. You'll need root or at least sudo access for changing files ownerships and probably also for doing the copy and extract too.
cp /tmp/mail-3.1.1.tar.gz .tar -zxvf mail-3.1.1.tar.gzchown -R www-data:www-data mail
Enable App
As an administrator user go to the Settings > Apps, or if you still have the page open refresh the page in the browser and it should now be showing as the downgraded version number

Click the Enable button to make the app available again.

Test
Test the downgraded application is working, preferably with a test plan that you've carefully designed to cover all of the apps functions.
In this case going into the mail app it was immediately obvious that it was working again as mailbox opened. Sending a test message confirmed it.
Repeat on the Live instance
Hopefully you're doing this on a test Nextcloud instance first. If all is well, or at least the downgrade fixes more problems than it creates, then run the same process again on your live instance.
Lessons Learned
After any sort of Oh$hit moment, sorry I mean incident to use the official ITIL term, it is good practice to review what happened and if there is anything that could have realistically been done differently to avoid it. Most of the time these come back to the same few things of course.
- Keep the test system in line with the live instance with respect to config and versions
- Properly validate app updates in test before doing them in live
- Apply and Test app updates separately from Nexcloud patches
- Keep a note of app versions and update history
- At least some apps can be downgraded if needed
The annoying part is the first two are standard practice in my day job. I should have known better and there's no excuse. I'd have had a few choice words of encouragement to say if one of our techies had ignored them. And with the benefit of hindsight the 3rd one is quite obvious too and from now on I will be applying app updates first and then doing the Nextcloud patches.
Bootnote
Just as I was finishing this write-up, Mail 3.2.1 was released. I've not tested it yet but I will update this article with the result. The github issue raised by Vasyugan hasn't had any update so I'm not hopeful.