Is it a backup if it is done locally? Is a backup efficient if it can only be done through a UI? I’ll answer both of those questions for you…no.
Backups done locally on a router serve little to no purpose. Only once has my router been reset and properly pulled a backup from itself. It has been reset over 5 times, unfortunately. What’s the answer to that? Go through my downloads folder and hope I backed something up manually through the UI in the last week or so.
This is not an efficient or effective solution. I need a way to automate my backups so in times when my UPS goes poof, the router says sayonara, and I want to get Kubernetes back up without having to re-set the static IP of all my nodes, I needed a much better backup solution.
So what I am saying is that with all of the people who also have Ubiquiti devices, nobody has figured out how to automate backups? Well, some people have, but after reading the countless Reddit, forum, and GitHub posts to no avail, I decided to do it myself.
Now I know, that using Selenium on a UI that is not yours (unplanned updates/UI changes) is not smart AT ALL, but take a long look at this Unifi API spec I found and come back with a script (that works) and then I would have already updated this stupid idea of mine for the next Unifi network UI.
So yes, I wrote a Selenium container that will backup my router on a scheduled interval and upload it to S3 (an optional feature) on a scheduled interval. This works for me and others, I hope whoever is reading this who also uses the Unifi network can use this as well:
services:
unifibackup:
container_name: unifibackup
image: 'jeffhardyski/unifibackup:0.1'
environment:
# AWS_ACCESS_KEY: ""
# AWS_SECRET_ACCESS_KEY: ""
# AWS_REGION: ""
# TARGET_BUCKET: "" # S3 Bucket Name
USERNAME: "" # Comment out if you do not need to set username
PASSWORD: ""
UNIFI_IP: "" # Router IP Address
BACKUP_INTERVAL: "72" # Defaults to 24 Hours
OUTPUT_DIRECTORY: "/output" # Defaults to "~/Downloads"
restart: unless-stopped
See more of the code in my GitHub repo.
One of the biggest parts of maturing my homelab is maturing my backups. Kubernetes backups, TrueNAS backups, and now Unifi backups. Soon I will chuck a few drives offsite and send backups there instead of Backblaze or S3.