Hackviking He killed Chuck Norris, he ruled dancing so he took up a new hobby…

27Feb/200

Unifi Controller Docker backup

Currently running my Unifi Controller as a docker container which works great. If you ever ended up with a broken Unifi Controller or Cloud Key you know the hassle it is to re-adopt and re-provision all your network gear to get back to square one. You should really keep track of the automatic backups from Unifi.

I'm using ryansch/unifi-rpi container which has more then 10 million pulls on docker hub. There isn't any information about handeling backups in the description which surprises me! It is however a pretty easy thing to setup properly. Since I'm running my Unifi Controller in docker on a Raspberry Pi Docker Swarm my biggest fear is to fry the SD card. If I fry the SD card on the docker node it will also fry the automatic backups the unifi controller writes to disk.

Automatic backups on the Unifi Controller.

If we look at the docker container we have a folder for the automatic backups /backup/autobackup. I have several NFS shares bound to y docker nodes via autofs that are located on my NAS which should be a much safer place for these backups.

Locate the backup dir

If we look at the source for this container on GitHub, we find that the working dir is /var/lib/unifi. If we then execute docker exec {containerID} ls we find a backup directory containing an autobackup folder. So that should mean that we have the backups at /var/lib/unifi/backup/autobackup. So we edit the service in docker, adding a volume binding against a node folder. In my case, I use /mnt/nfs/backups/docker_unifi which is mounted from my NAS on the docker node.

Swarmpit volume mount

Then we can set the auto backup occurrence to every hour and schedule it in the next 5 minutes. We see that unifi puts out an autobackup file and metadata in JSON format on disk. This means we have a safe backup on our NAS. We can now schedule it to something more realistic like once every week or day depending on how much you change your setup.

Posted by Kristofer Källsbo

Comments (0) Trackbacks (0)

No comments yet.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

No trackbacks yet.