Published onAugust 30, 2024by Iron (edited on November 20, 2024)

Updating your UniFi Controller on Ubuntu is one of those tasks that seems intimidating at first, but once you get the hang of it, it’s pretty straightforward.

Whether you’re running a small home network or managing multiple sites, keeping your UniFi Controller up to date is crucial for ensuring security, stability, and access to the latest features.


Why you should update your UniFi Controller

Before diving into the how, let’s quickly chat about the why. Updating your UniFi Controller is important for a few key reasons:

  • Security patches: Security vulnerabilities are an unfortunate reality of the tech world. Updates often include patches that protect your network from potential threats.
  • New features: Ubiquiti is constantly improving their software. Updates bring new features that can enhance how you manage your network.
  • Bug fixes: If you’ve been experiencing glitches or issues, the latest update might have the fix you need.

In short, regular updates keep your network secure, efficient, and running smoothly. Now, let’s get into the nitty-gritty of updating your UniFi Controller on Ubuntu.

Step 1: Prepare your system

Before we do anything, it’s essential to make sure that your system is ready for the update. Here’s what you need to do:

  1. Backup your UniFi Controller: Always start with a backup. This is your safety net in case something goes wrong during the update process. You can back up your UniFi Controller data with the following command:sudo mongodump --archive=/var/backups/unifi_backup.archive This command will create a backup file that you can restore if necessary. Store it somewhere safe—better to be safe than sorry!
  2. Check your current version: It’s helpful to know what version you’re currently running. You can find this by logging into your UniFi Controller dashboard and checking the version number in the lower-left corner.
  3. SSH into your Ubuntu server: You’ll need to access your server via SSH. Open your terminal and connect to your server using:ssh username@your-server-ip Replace “username” with your actual username and “your-server-ip” with the IP address of your server.

Step 2: Stop the UniFi service

Before starting the update, it’s a good idea to stop the UniFi service. This helps to prevent any conflicts during the update process. Run the following command:

sudo systemctl stop unifi

This command will stop the UniFi service gracefully. You can check the status to confirm it’s stopped by running:

sudo systemctl status unifi

Make sure it says “inactive” before proceeding to the next step.

Step 3: Add the Ubiquiti repository (if not already added)

If you’ve updated your UniFi Controller before, you might have already added the Ubiquiti repository. If not, you’ll need to add it now to ensure you’re installing the latest version. Here’s how:

  1. Add the repository:echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt.list
  2. Add the GPG key:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50

This step ensures that your system can trust the packages you’re about to install.

Step 4: Update the package list

Now that the repository is set up, you need to update your package list to ensure you have the latest packages available. Run the following command:

sudo apt-get update

This command will fetch the latest package lists from the repository, making sure that you’re about to install the latest version of UniFi.

Step 5: Upgrade the UniFi Controller

With everything in place, it’s time to update the UniFi Controller. Simply run:

sudo apt-get upgrade unifi -y

This command will automatically upgrade your UniFi Controller to the latest version available in the repository. Depending on your internet speed and the size of the update, this might take a few minutes.

Step 6: Start the UniFi service

Once the update is complete, you’ll need to start the UniFi service again. Run the following command:

sudo systemctl start unifi

After starting the service, you can check its status again to ensure it’s running:

sudo systemctl status unifi

It should say “active (running)” if everything went well.

Step 7: Verify the update

The final step is to verify that the update was successful. Log into your UniFi Controller dashboard and check the version number. It should now reflect the latest version.

If everything is running smoothly, congratulations—you’ve successfully updated your UniFi Controller!

Troubleshooting common issues

Sometimes things don’t go exactly as planned. Here are a few common issues you might encounter during the update process and how to fix them:

  • The controller won’t start: If your UniFi Controller doesn’t start after the update, check the logs for any errors. You can view the logs by running:sudo journalctl -u unifi.service Look for any errors that might indicate what went wrong.
  • Can’t access the web UI: If you’re unable to access the UniFi web interface after the update, ensure that the firewall isn’t blocking port 8443, which is used by UniFi.
  • MongoDB issues: Sometimes MongoDB might not start correctly after an update. If this happens, try restarting MongoDB:sudo systemctl restart mongodb Then try starting the UniFi service again.
  • Roll back to a previous version: If all else fails and you need to roll back to the previous version, you can restore your backup with the following command:sudo mongorestore --archive=/var/backups/unifi_backup.archive This will restore your UniFi Controller to the state it was in before the update.

Automating updates (Optional)

If you prefer not to manually update your UniFi Controller every time there’s a new release, you can automate the process. Here’s a basic way to set it up:

  1. Create a bash script: Write a script that includes all the commands we’ve just gone through. Save it to your server.
  2. Set up a cron job: Use cron to schedule the script to run at regular intervals, for example, once a month. Here’s how you can set up a cron job:crontab -e Add the following line to run the script at 2 AM on the first day of every month:0 2 1 * * /path/to/your/script.sh This will automate the update process and keep your UniFi Controller up to date without any manual intervention.

Final thoughts

Updating your UniFi Controller on Ubuntu doesn’t have to be a chore. With this step-by-step guide, you can easily keep your network secure and running smoothly. Regular updates are essential to maintaining a reliable and safe environment, especially if you’re managing multiple sites or handling sensitive data.

And if you’re tired of managing these updates yourself, consider using a hosting service like UniHosted. We handle updates, backups, and monitoring for you, so you can focus on what really matters—running your network efficiently.If you would like me to personally walk you through UniHosted, you can schedule a call with me here.