Issue with docker images and upgrade

I try to upgrade my nextcloud version, by doing a docker-compose pull and docker-compose up -d, which apparently got me to nextcloud 17.0.0.9.

I was on 15.0.5.3, as is found in my config.php, so I got the unfortunate “Updates between multiple major versions and downgrades are unsupported.”.

Now, I tried to get back to versin 15, by forcing the tag nextcloud:15 on the images, and I get:

Can’t start Nextcloud because the version of the data (17.0.0.9) is higher than the docker image version (15.0.12.1) and downgrading is not supported. Are you sure you have pulled the newest image version?

So I cannot upgrade from 15 to 17, but my data have already been converted to 17… What can I do now?

Do you happen to have a backup of your config.php (stored in ./config) file from version 15? I don’t know what the exact version string needs to be set to, but that is important. I think you also might need to pull a backup of version.php (stored in the root).

Your data should still be intact, and since the upgrade to 17 did not work, it would not have run any migrations on the database either, so it should only be a matter of telling Nextcloud the correct version (15) that you are running.

My config.php is untouched I think, it still has the "version" => "15.0.3" inside, but when I run php occ status it tells me 17.0.0.9.

I tried setting 17.0.0.9 manually and running occ upgrade and it apparently worked, but I am not sure if I missed something.

What does your version.php file look like? I think that’s the key.
And I would strongly recommend not trying to force the upgrade, just run version 16 and do the upgrade, then from there upgrade to 17.

My version.php looks like this:

$OC_Version = array(17,0,0,9);
$OC_VersionString = '17.0.0';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' =>
  array (
    '16.0' => true,
    '17.0' => true,
  ),
  'owncloud' =>
  array (
  ),
);
$OC_Build = '2019-09-26T08:24:52+00:00 c937c8f1753b111086e28afa396f3abd5776b1db';
$vendor = 'nextcloud';

But this is after the upgrade. I don’t know what it looked like before, but as I said, occ status was giving me:

  - installed: true
  - version: 17.0.0.9
  - versionstring: 17.0.0
  - edition:

Ok, so your version.php needs to be rolled back to version 15. It should be exactly this:

<?php
$OC_Version = array(15,0,12,1);
$OC_VersionString = '15.0.12';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' =>
  array (
    '14.0' => true,
    '15.0' => true,
  ),
  'owncloud' =>
  array (
  ),
);
$OC_Build = '2019-09-25T18:33:20+00:00 dc990963f35e94d568a3b4874c839e121622abdd';
$vendor = 'nextcloud';

Then go ahead and try running version 16 to see if you can upgrade (from 15 to 16).

I cannot really do this now, the migration to 17 is done, so everything has been migrated, including the database (and, I assume, the data, even if this seems to have been done prior to my manual upgrade… ).

I don’t really understand why version.php was migrated but not the rest of the project… And the warning I got when trying to use version 15 or 16 was about the data being in a too higher version, so was this warning related to version.php only?

No, I don’t think the database migration took place since you jumped from 15 to 17. I think the wording is misleading about the data version being set to 17. Nothing happens to your actual data when upgrading, only changes in the database.

It sounds like what happened is that when you ran version 17, it replaced version.php before checking if it could complete the upgrade (then failed). I think that is probably a bug.

At this point, you should definitely make sure you have a backup of your data and of the database. The next step would definitely be to roll back version.php to 15 and then run Nextcloud version 16 to see if it can complete the upgrade. Or run 15 first just to see if it’s working.

No, I don’t think the database migration took place since you jumped from 15 to 17. I think the wording is misleading about the data version being set to 17. Nothing happens to your actual data when upgrading, only changes in the database.

I think you misunderstood one of my previous comment. I tried “fooling” by setting version manually in config.php and running occ upgrade and it seems to have worked, the database was migrated, and I am now running version 17, which is why I cannot roll back version.php and try upgrading again (well I could but I am pretty confident on the error message I’d get if I tried).

Ah, I understand now, you manually set the version in config.php and ran occ upgrade which seems to have run successfully.

Ok, so are you actually running Nextcloud on version 17 (then we are done?), or are you still having some problem?

If I had to guess, knowing a little bit about how to program database migrations, is that the 16-17 migrations were applied to the database, but not the 15-16 migrations (and now it is impossible or would need to be done manually, not even sure where to start with that).

If that is the case, I really hope you have a backup of your SQL database (and if you don’t, what are you waiting for!?). Even if things seem to work, I personally would not trust the state of the database. There is a reason they don’t support upgrades across major versions, so trying to trick it into working will only lead to trouble down the road.

Ok, so are you actually running Nextcloud on version 17 (then we are done?), or are you still having some problem?

Yes, I was just wondering if there could be some hidden issues, as you mention with the database. I will monitor the server closely and see if anything suspicious happens or try to run some health check if possible.

Thanks for your help and time anyway!

1 Like

Interesting! :slight_smile: Well I’m glad it’s working for you, and now you know about upgrading one version at a time!

Two things I will also add to this as far as backup. I run VMware ESXi and take a snapshot before upgrading and keep it for a couple days or more before merging.

If you aren’t running a virtual machine, you can also duplicate or export your Docker volumes before upgrading I believe, although I don’t know the commands off the top of my head.

1 Like

I have the same issue. Nextcloud ran smoothly in the background for a while. One evening I try to access my photos and the damn thing is in maintenance mode! I had to match dates in the logs to figure out how Nextcloud decided to jump two versions and brick itself.

With the help of the kind people above I found my true version (18). I set the docker image to :18-fpm, hoping I could just go back to where I started, but I get…

Can’t start Nextcloud because the version of the data (20.0.2.2) is higher than the docker image version (18.0.11.2) and downgrading is not supported.

I can’t access the container, because it’s stuck in a boot loop:

Container 35c735fe85997e9853914cc91879512b8dab91624033222940b365bd3c9a53f3 is restarting, wait until the container is running

This makes me very wary of using Nextcloud for anything remotely important. It shouldn’t be able to brick itself so easily.