Skip to content

Instantly share code, notes, and snippets.

@johndturn
Created April 25, 2022 21:41
Show Gist options
  • Save johndturn/baaa3c7d2cf8c607f88fc248d440f6f3 to your computer and use it in GitHub Desktop.
Save johndturn/baaa3c7d2cf8c607f88fc248d440f6f3 to your computer and use it in GitHub Desktop.
How to uninstall and reinstall the Ubiquiti Unifi controller software on a Raspberry Pi (or other Linux environment), and restore from a Backup

Restoring Unifi Controller

Today I woke up and realized that a power surge a while back had taken down our Unifi controller without me realizing. I went to log in to check on firmware updates for the network only to see that I couldn't log in at all. I guess that's the benefit of hosting your controller via a CloudKey Gen 2 with a built-in on-device battery vs. on a Raspberry Pi like I do.

That said, restoring from scratch was actually super easy, given that I had regular backups. Here's the process and some additional reading that I used.

Assumptions

  • You're running the most recent version of the Ubiquiti Unifi controller on a Raspberry Pi (or other Debian-based Linux-based environment)
  • You already have your self-hosted environment set up with a static IP address, and can access it via ssh or through a command line interface
  • You already added the repo directly to apt for managing installing and updating unifi
  • You have a recent backup of your controller setup / data

Note: If you don't have all of this set up already, and are instead looking for a primer on getting it set up from scratch, follow the link in the Further Reading section below on How to Host Unifi Controller on Raspberry Pi

Steps

  1. Uninstall the Unifi controller: sudo dpkg -P unifi
    • Note that in this article here it recommends that you fully delete the /usr/lib/unifi/data directory. I did NOT do this and was totally fine
  2. Update your package references: sudo apt-get update
  3. Install the most recent Unifi distribution: sudo apt install unifi
  4. Wait for the installation and the bootstrapping of the webserver
  5. Navigate to your static IP for the controller, specifically to port 8443
    • You'll need to accept the self-signed certificate
  6. Click through the wizard to find the "Restore from Backup" button
    • Should be pretty early on in the process, if not on the very first screen
  7. Upload the backup
  8. Wait for the restoration to finalize
    • The page will reload for you automatically and forward you to the login screen that should be familiar
  9. When you log in, you'll notice all of your Unifi devices will start adopting
  10. Waiting for the adoption process to finalize. Note: Your APs will likely stop broadcasting the network momentarily while this adoption process will occur
    • My network was unavailable for like 30secs.
  11. You're done!

While the above seems like a lot of steps, it was actually super straightforward and just involved some waiting.

Further Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment