How to upgrade a Unifi Controller on a RaspberryPi

Something I keep meaning to do is upgrade my Unifi network controller that I have a on Pi. It’s an important thing to do too due to the security risk.

It was so long since I last did it I really couldn’t remember how I installed it, so I had to faff a bit and thought I’d share my process.