Cannot upgrade from 20.0.10 to 21.0.1

I have nextcloud installed in a docker (unraid) using mariadb (10.5.12-MariaDB-log) in a separate docker.
For some reason when trying to do the upgrade I get the following error:

docker exec -it nextcloud occ upgrade

Setting log level to debug
Updating database schema
Exception: Database error when running migration latest for app core
Update failed
Maintenance mode is kept active
Resetting log level

I used the manual upgrade method since the web gui one did not work.

I did search the web for a solution but none of the options worked for me.

Would appreciate any help to troubleshoot this, also if there is any solution to do a clean install and “reuse” the config.php and the mariadb database please let me know.

P.S. Below are the commands used for the upgrade:

docker exec -it nextcloud occ maintenance:mode --on
docker exec -it nextcloud mv /config/www/nextcloud /config/www/nextcloud-backup
docker exec -it nextcloud wget https://download.nextcloud.com/server/releases/nextcloud-21.0.1.tar.bz2 -P /config
docker exec -it nextcloud tar -xvf /config/nextcloud-21.0.1.tar.bz2 -C /config/www
docker exec -it nextcloud cp /config/www/nextcloud-backup/config/config.php /config/www/nextcloud/config/config.php
docker restart nextcloud
…..wait….for nextcloud to start…..
docker exec -it nextcloud occ upgrade

Have you checked nextcloud.log / updater.log ?

This is what I get when trying to update from the webgui:
Screen Shot 2021-11-02 at 9.51.07 PM

the updater.log is missing from my /data folder as for the nextcloud.log this is the portion that deals with the upgrade.

{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:20+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::setDebugLogLevel: Set log level to debug","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":0,"time":"2021-11-03T01:39:20+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"starting upgrade from 20.0.10.1 to 21.0.1.1","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Repair::step: Repair step: Repair MySQL collation","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OC\\Repair::info: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Repair::info: Repair info: All tables already have the correct collation -> nothing to do","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Repair::step: Repair step: Repair SQLite autoincrement","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Repair::step: Repair step: Copy data from accounts table when migrating from ownCloud","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Repair::step: Repair step: Drop account terms table when migrating from ownCloud","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:21+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::dbUpgradeBefore: Updating database schema","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":3,"time":"2021-11-03T01:39:22+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":{"Exception":"Exception","Message":"Database error when running migration latest for app core","Code":0,"Trace":[{"file":"/config/www/nextcloud/lib/private/Updater.php","line":302,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":249,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":132,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/core/Command/Upgrade.php","line":255,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/occ","line":11,"args":["/config/www/nextcloud/console.php"],"function":"require_once"}],"File":"/config/www/nextcloud/lib/private/DB/MigrationService.php","Line":430,"Previous":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":1932,"Trace":[{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1728,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1667,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1040,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":226,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":256,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":90,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":524,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":541,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":426,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":302,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":249,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":132,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/core/Command/Upgrade.php","line":255,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/occ","line":11,"args":["/config/www/nextcloud/console.php"],"function":"require_once"}],"File":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":114,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":1932,"Trace":[{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":87,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1035,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":226,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":256,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":90,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":524,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":541,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":426,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":302,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":249,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":132,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/core/Command/Upgrade.php","line":255,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/occ","line":11,"args":["/config/www/nextcloud/console.php"],"function":"require_once"}],"File":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":"42S02","Trace":[{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":82,"function":"query","class":"PDO","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1035,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":226,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":256,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Migrator.php","line":90,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":524,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":541,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/MigrationService.php","line":426,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":302,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":249,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/lib/private/Updater.php","line":132,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/core/Command/Upgrade.php","line":255,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/3rdparty/symfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/config/www/nextcloud/occ","line":11,"args":["/config/www/nextcloud/console.php"],"function":"require_once"}],"File":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":82}}},"CustomMessage":"--"},"userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":3,"time":"2021-11-03T01:39:22+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::failure: Exception: Database error when running migration latest for app core","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":3,"time":"2021-11-03T01:39:22+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::updateEnd: Update failed","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:22+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::maintenanceActive: Maintenance mode is kept active","userAgent":"--","version":"20.0.10.1"}
{"reqId":"KQkijN7YmtMWBZHTGGA6","level":1,"time":"2021-11-03T01:39:22+00:00","remoteAddr":"","user":"--","app":"updater","method":"","url":"--","message":"\\OC\\Updater::resetLogLevel: Reset log level to Debug(0)","userAgent":"--","version":"20.0.10.1"}
{"reqId":"dYdJjLc4h89xACnfeMjL","level":0,"time":"2021-11-03T01:40:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Update required, skipping cron","userAgent":"--","version":"20.0.10.1"}

This issue is now closed, I did not fix the problem that seems to be because of some corruption in my mariadb database all I did was to restore a week old database from a backup I had and now I’m running 22.2.0 just fine. If this issue comes back I will dig deeper for now I will move to other more pressing issues.