ryansch / docker-unifi-rpi

Unifi Controller for Raspberry Pi 3+ and x86
https://hub.docker.com/r/ryansch/unifi-rpi/
347 stars 42 forks source link

Mongo Upgrade! #95

Closed ryansch closed 2 months ago

ryansch commented 2 years ago

Why?

We have to upgrade mongo because we can't get packages for the incredibly old 2.x series any longer. This is also why I had to drop support for 32-bit rasperry pis (arm32).

We are able to grab packages from Ubuntu Xenial for mongo 3.6 so that's the way forward. (Many thanks to GLENNR on the unifi forums! Website here: https://glennr.nl)

How?

First we're now spitting out this message when you upgrade the container from a version running mongo 2.4 to one running 3.6:

Older mongodb files detected!
We've been forced to upgrade mongodb to version 3.6.
You must back up your unifi network application, remove all docker volumes,
start up unifi, and restore from backup during setup.

This puts the power to schedule the upgrade in the hands of the end user. If you're here because of that message, you can pin the previous working version in compose.yml and bring your controller back up.

If you're ready to upgrade, you need a recent backup generated by the unifi controller. If you need to download one, pin the last working version and bring the controller back up to generate and download said backup.

Once you have your backup in hand, run docker compose down -v from your unifi directory. This will DELETE ALL OF YOUR DOCKER VOLUMES for unifi. Please only do this step once you're ready.

Next bring the new version of the controller up and instruct the setup wizard to restore from backup.

If you're having issues or have helpful information, please post it below!

loganmarchione commented 2 years ago

@ryansch thanks for this! It's a shame that you weren't able to do an in-place upgrade, but it's probably for the best (letting the users control it). It's also a shame that Ubiquiti chose MongoDB, and that they don't support a modern version of it.

I did the upgrade and had zero issues. Took 5 minutes total. For anyone who finds this and wants to upgrade, here is what I did:

  1. Connected via a WIRED network (don't skip this step)
  2. Take backup of controller from here (it will generate a .unf file)
  3. Backup (cp -pr) the old volume (just to be safe)
  4. docker compose down -v
  5. Change UniFi image version in docker-compose file (I went with 7.2.92)
  6. docker compose up -d
  7. Navigated to UniFi URL, restored via backup file, waited about 5 minutes, everything showed up (APs and clients)

This is from inside the container. Shiny new MongoDB:

root@54551b684b16:/var/lib/unifi# mongod -version
db version v3.6.23
...
...
root@54551b684b16:/var/lib/unifi# cat /var/lib/unifi/db/WiredTiger.turtle
Compatibility version
major=3,minor=0
WiredTiger version string
WiredTiger 3.1.1: (July 12, 2018)
...
...

I'm going to keep an eye out for issues in the next few days, but so far, so good! Thanks again!

loganmarchione commented 1 year ago

@ryansch FYI that 7.5.172 requires MongoDB 3.6 or newer.

https://community.ui.com/releases/UniFi-Network-Application-7-5-172/a0cd43eb-773a-4497-a832-bbb493cbe4ee

ryansch commented 8 months ago

@loganmarchione I'm finally dealing with this.

mafrosis commented 2 months ago

@ryansch Do you need any help with this? I'm keen to get onto 8.1.

EDIT: reading the post above from @loganmarchione, it seems that a simple backup/upgrade/restore cycle is the process to move onto Mongo 3.6?

ryansch commented 2 months ago

I just tried shipping mongo 7 only to find that only pi 5s can run it. That's not going to work for a more general purpose docker container.

ryansch commented 2 months ago

It looks like we'll need to work with 4.4.

ryansch commented 2 months ago

I just shipped 8.1 with mongo 4.4.18. Works on my pi4.

Drel commented 1 month ago

Backed up my UniFi config and volumes, followed @loganmarchione 's steps above, and everything seems to work fine. It automatically restarted and seemed no worse for wear; devices were adopted correctly and all functionality seems to be present. This was an update from 8.0.7 to 8.2.93.

@ryansch Thank you so much for continuing to maintain this, and taking steps like this to keep up to date.