Stuck in Upgrade Loop 27.1.2

Nextcloud version : 27.1.2
Operating system and version (eg, Ubuntu 20.04): Debian GNU/Linux 11 (bullseye)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.56
PHP version (eg, 7.4): 8.1

The issue you are facing:

I was updating from 27.1.1 to 27.1.2 and got stuck in a loop. I was using the web interface and things seemed to progress smoothly and the update seemed to be completing but then when it refreshed and should have come out of upgrade/maintenance mode it then presented the update screen saying " Nextcloud will be updated to version 27.1.2" and offered a “START UPDATE” button again. It will repeat this forever. I have tried performing the update from the command line with no success.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Attempt an upgrade

Here is what I get when I check status via occ :

sudo -u www-data php occ status

Nextcloud or one of the apps require upgrade - only a limited number of commands are available                                                                                                                                               You may use your browser or the occ upgrade command to do the upgrade.
installed: true
version: 27.1.2.1
versionstring: 27.1.2
edition:
maintenance: false
needsDbUpgrade: true
productname: Nextcloud
extendedSupport: false   

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
'instanceid' => '',
'passwordsalt' => '',
'secret' => '',
'trusted_domains' =>
array (
0 => '',
1 => '',
2 => '',
3 => '',
),
'datadirectory' => '/ncdata',
'dbtype' => 'mysql',
'version' => '27.1.2.1',
'overwrite.cli.url' => '',
'dbname' => '',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => '',
'dbpassword' => '',
'installed' => true,
'htaccess.RewriteBase' => '/',
'default_phone_region' => 'US',
'filelocking.enabled' => true,
'memcache.locking' => '\\OC\\Memcache\\Redis',
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '/var/run/redis/redis-server.sock',
'port' => '0',
),
'maintenance' => false,
'app.mail.verify-tls-peer' => false,
'mail_smtpmode' => 'smtp',
'mail_smtpsecure' => 'ssl',
'mail_sendmailmode' => 'smtp',
'mail_domain' => '.com',
'mail_from_address' => '',
'mail_smtpauthtype' => 'LOGIN',
'theme' => '',
'allow_local_remote_servers' => true,
'loglevel' => 1,
'app_install_overwrite' =>
array (
0 => 'wopi',
),
'mail_smtpport' => '1025',
'memories.exiftool' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
'memories.vod.path' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
'memories.vod.ffprobe' => '/usr/bin/ffprobe',
'updater.secret' => '',
);

Have you tried to use occ upgrade from command line?
Have you updated columns and primary keys by occ command?

Yes I have tried both.
It completes the upgrade as though everything went as planned but then I end up back at the “Start Update” if I tried to load the site.
If I run any occ command I see this banner "Nextcloud or one of the apps require upgrade - only a limited number of commands are available You may use your browser or the occ upgrade command to do the upgrade "

I have tried to change the version in config/config.php and that seems to have had an effect in the sense that when I run occ status I get this now.

sudo -u www-data php occ status
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
- installed: true
- version: 27.1.2.1
- versionstring: 27.1.2
- edition:
- maintenance: false
- needsDbUpgrade: true
- productname: Nextcloud
- extendedSupport: false

How is “needsDbUpgrade” set or determined? Would this be enough to put my system in this state?

Thanks in advance for any help/suggestions!

What do you get after this command

sudo -u www-data php occ config:system:get version

so as following

sudo -u www-data php occ maintenance:repair
?

for very good reason i am using the command line updater.phar for updating my nextcloud for a long time now.

I will give you a link to a (in my opinion) very very good tutorial and some commands that could rescue your NC installation.

I had same situation years ago. My solution was to copy over all NC installation files from the tar.gz file that has to be downloaded from nextcloud.com. After backing up my NC folder i copied over the new files in place and ran the occ upgrade command again.
If that doesn’t help, you may (backup before is obligatory!!) copy the files of an older NC version (downloaded tar.gz file!) to your NC root and then start the command for the updater.phar

→ read this: Upgrade via built-in updater — Nextcloud latest Administration Manual latest documentation

sudo -u www-data php occ config:system:get version
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
27.1.1.0

I ran the other command you suggested and it “did all the things” with no issues. I checked the version again using the command you suggested and got the same result.

OK your Updater is reporting a still open “occ upgrade” because your NC version wasn’t properly changed by the (WebUI) Updater in my opinion.

What you do is your your choice! I would try the following

  1. make a backup of the whole NC folder (root dir) maybe /var/www/nextcloud/…
  2. download the latest files for NC 27.1.1 Server as tar-gz
  3. unpack all the content of the packed files to maybe /tmp/nextcloud
  4. copy over all folders and files from the unpacked folder /tmp/nextcloud to your root dir maybe /var/www/nextcloud
  5. DO NOT OPEN ANY BROWSER → WebUI of your Nextcloud!
  6. check that your www user (maybe www-data) has full read write access to your files and folder in NC root dir (e.g. /var/www/nextcloud) and that the old config in …/nextcloud/config/config.php still resist!
  7. run the following command
    sudo -u www-data php /var/www/nextcloud/updater/updater.phar
  8. follow the instructions on the terminal screen
  9. after successful upgrade (occ upgrade) do further
    occ db:… and (add missing columns indices etc.)
  10. be sure that maintenance:mode is set to off (occ maintenance:mode --off )
  11. make a reboot of the NC Server (not just the services restart!)
  12. after reboot log into terminal again and check the integrity of the core by occ command
    if everything is ok now, then go back to browser and open your NC URL

Keep my fingers crossed this work :+1:

I will try this today. Thanks for they help so far!

Still having the same issue.

Still stuck in the update loop.
Any time I run the occ command I get this header :

Nextcloud or one of the apps require upgrade - only a limited number of commands are available                                                                                                                                               You may use your browser or the occ upgrade command to do the upgrade
Nextcloud 27.1.2 
sudo -u www-data php occ status
Nextcloud or one of the apps require upgrade - only a limited number of commands are available                                                                                                                                               You may use your browser or the occ upgrade command to do the upgrade 
- installed: true
- version: 27.1.2.1
- versionstring: 27.1.2
- edition:
- maintenance: false
- needsDbUpgrade: true
- productname: Nextcloud
- extendedSupport: false     

What triggers that header?
What triggers the update page?

OK so an update. I copied he contents of 27.1.1 to my nextcloud directory and… well it works. If I try to run the update/upgrade I get stuck in the loop. I think I am going to hold tight here for the moment to see if things go smoothly.

Thanks for all of the help so far! I may just wait for the next update before trying again.

After copying the raw files of the 27.1.1 tar.gz to the nextcloud root dir do you run occ upgrade directly or do you at first run the updater.phar command?

When the updater.phar recognize the files version that is installed and offers to download the new (27.1.2 at the moment) version a download → files overwrite → maintenance … should be the result.

When the script ask to “occ upgrade” then this happens usually after the download and files exchange process…

Do you have any apps that are not yet compatible with the 27.1.2 occ app:list
looking for enabled / disabled apps that might be disabled during update / upgrade process?

– This is entirely possible. I will dig through those and remove what is not compatible and try again later.

Thanks for the help!!