Skip to content

Instantly share code, notes, and snippets.

@darrenpmeyer
Created December 23, 2020 02:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darrenpmeyer/44f853ac52201fff046c1146acaaac64 to your computer and use it in GitHub Desktop.
Save darrenpmeyer/44f853ac52201fff046c1146acaaac64 to your computer and use it in GitHub Desktop.
Decrypt Unifi .unf backups

NB: these instructions are for Ubuntu; they work under WSL on Windows 10 as well

Get the decrypt.sh file from here: https://github.com/zhangyoufu/unifi-backup-decrypt

Make sure prerequisites are installed:

sudo apt update && sudo apt install zip unzip openssl mongo-tools

Then put your .unf backup file somewhere convenient (for our example, we'll assume it's in the home directory and named backup.unf):

bash decrypt.sh ~/backup.unf ~/backup.zip
mkdir backup
cd backup
unzip ~/backup.zip
gunzip db.zip
bsondump db.zip > db.json

This will:

  1. convert the .unf into an unencrypted .zip file,
  2. unzip that into the backup directory,
  3. uncompress the backup database
  4. convert the backup databse from "binary JSON" (bson) to plain text JSON

You can then see the contents of the backup database with any JSON-aware tool or simply read it in a text editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment