Updating using docker-compose

So I have been running nextcloud 21 for a while.

Setup was done via docker-compose.

Now I wanted to update to 22. I tried the web updater but it doesn’t work (I click on update and it just reloads the page). So I tried the cli and that “seemed” to work but the update process got stuck in maintenance mode. And turning maintenance mode prooved impossible.

Then I found this (Docker Hub):

When using docker-compose your compose file takes care of your configuration, so you just have to run:

$ docker-compose pull
$ docker-compose up -d

But when I do this (I changed the docker-compose file to point to “22-apache”), it again seemed to work. But this time, I got a fresh install!?! I was prompted to create an admin password etc.

So, finally, here is my question: How can I update an existing nextcloud installation via docker-compose without installing everything from scratch?

Thanks in advance!!!

if you end up with fresh install it looks like you didn’t keep your data. you are expected to store your DB, files and apps on persistent docker volumes, which you keep when you change the docker-compose file. then new docker image finds existing data and performs an upgrade…

Thing is - I do store everything outside the container: the files, the config, the database.

I am using the original docker-compose file that I used to set it up in the first place and which creates the docker volumes.

(Luckily, I made a backup prior to the update. So I can go back to the original state and try again.)

Okay, so I figured out what the problem was:

The disk on which the docker volumes reside went missing from the VM (inside which docker lives). Now that I have attached the disk again, I don’t see a new install issue anymore.

But I do have another problem now:

When I first tried to update via docker-compose, it pulled version 23 (note that I was still on 21). Nextcloud does not support updating skipping one number. So in my next try I changed the docker-compose file to pull “22-apache”.

But when I now recreate the nextcloud container with 22, I get an error message that the data is already on version 23 and that this does not work with nextcloud 22.

So while the first update did not go through, it did change the version number of my data. And now I am stuck.

How can I change back the version number of my data?

Thanks!

the easiest way would be to restore your working NC21 and perform update one per step. If this is not an option there are multiple thread in this forum describing how people recovered from such situation.

My nextcloud installation is backed up independently from the data (and the database).

So, in addition to the nextcloud installation, what else do I need to restore? I.e. is it enough to restore the database (maybe the version number is only stored in there) or do I need to restore the data itself as well?

Assuming (hoping), it is only the database - which files specifically?

Thanks!

PS
If there are already a lot of threads about recovering from a failed update where the update did not go through but the version number of the data was still changed, maybe it should be considered to change the update process (i.e. only change the version number at the end, if the update actually worked)?

you should never separate the backup in different part (database and data) as they belong together. Please take a look at the official backup instructions.

version number is part of the docker container and it exists within the container from the beginning… I assume it is added to config files even before the application has started. Feel free to check out the Dockerfile and improve the upgrade process

What I meant to say was that my nextcloud installation is backed up indepedently from the data and the database while the data and the database are backed up together.

But I would rather only restore the database without the data (I can restore on a file by file basis), if it is not necessary to also restore all data.

When you are saying that the version number is wirtten to config files - would it be sufficient to edit the config file instead of restoring the database?

Thanks

So I was able to work it out (with the help of another thread on the forum):

It is not necessary to restore all the data and it is not even necessary to restore the database.

It was sufficient to restore /html/version.php. In my case it contained 23.0.0.1 and the backup version.php I restored contained 22.1.1.2. After I restored it and restarted Nextcloud, it complained that a large number of apps had the wrong version (which is not surprising, because originally - prior to the failed update - I was on 21).

So I pulled the latest 22 image, recreated the containers and after a while my Nextcloud was up and running again.

Probably, it would have been more straight forward to use an even older backup version of version.php that contained my true 21 version number but I had that one right there and did not want to spend any more time.

I will monitor everything for a while to be sure that everything is fine and then I will update to 23.

Thanks