This post is deprecated. I have moved on to other techniques and no longer endorse this advice.

Perhaps you’re asking yourself, what would I do if my Dream Machine Pro died? Aside from the issue of replacing the hardware and having your network down until you do, the UDM-Pro is a UniFi controller, so you’ll need a .unf file to restore from.

First, make sure you have Auto Backup configured.

https://help.ui.com/hc/en-us/articles/226218448-UniFi-How-to-Configure-Auto-Backup

Once that’s done, I like to take a simple approach. I’ll create a cron job on the UDM-Pro that runs rsync to copy the files to an instance I have set up for the purpose of housing backups. For me that’s a vm that has an nfs share from my freenas mounted, but a cloud instance would be fine.

Establish an SSH connection to your UDM-Pro.

ssh root@unifi

Establish a shell connection to unifi-os and switch to the home directory while we’ll keep our script.

unifi-os shell
cd ~

By default, there won’t be a public key associated with the private key. Let’s generate one.

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

Install vim and rsync. Replace vim with nano if you aren’t familiar with vim.

apt update
apt install vim rsync -y

Let’s try run our backup command. Replace root@unifi-backup with the username and hostname or IP address of your backup instance. Replace unifi-backup/ with the remote path where you want to rsync the backup files.

rsync -av /data/unifi/data/backup/autobackup/*.unf root@unifi-backup:unifi-backup/

That should have worked. Now let’s automate it.

Make a backup.sh file and make it executable.

touch backup.sh
chmod +x backup.sh

Edit the backup script. Replace vim with nano if you aren’t familiar with vim.

vim backup.sh

It should look a bit like this. Use the command that you previously tested with your replacements.

#!/bin/bash
rsync -av /data/unifi/data/backup/autobackup/*.unf root@unifi-backup:unifi-backup/

Test it.

./backup.sh

Make it a cron job.

crontab -e

Add a line to run the backup script. I’m going with hourly. It’s such a small job that it won’t hurt to run it often.

0 * * * * /root/backup.sh

Document the backup location so it’s readily available when you need it.