2 min read

Backing up Unifi Protect

Backing up Unifi Protect
Photo by Andrea De Santis / Unsplash

A few weeks ago, I was scrolling through the r/Ubiquiti Subreddit when I came across a post where someone had their NVR stolen during a break in. We have a number of Protect cameras across the house and the post got me thinking... I have offsite backups of data stored on the NAS, but not the NVR. A lot of the recordings are useless, but it would be really nice to have the events stored offsite for a few days, just in case.

Luckily, the comments of the original post (which I can't find anymore) had a bunch of helpful suggestions, one of which being to run unifi-protect-backup on a Raspberry Pi. However, because Pis are in short supply right now, and because I don't love running Pis for production workloads, I wanted to run the backups from the NVR itself. I thought that the NVR had enough spare CPU and Memory to do the work, and had all the data available locally, but boy was I mistaken.

Since I wanted to both encrypt and compress the video files before uploading them, this turned out to be a computationally expensive operation and when run on the NVR, would result in a lock-up that would only be resolved by a power-cycle.

Since I had recently started using Nomad for my Container Orchestration, I opted create a Nomad Job for this task and have the job run from one of my servers, where significantly more CPU was available, and I did not risk locking up the NVR. The Nomad Job configuration ended up being much simpler than the work needed to get the backups running on the NVR (especially since the NVR likes to reset things after updates).

terraform-hashi/backup-unifi-protect.hcl at main · tpaulus/terraform-hashi
Hashicorp Product (Nomad, Consul, etc.) Terraform Configurations - terraform-hashi/backup-unifi-protect.hcl at main · tpaulus/terraform-hashi