unifi-protect-recovery
GUI + CLI to back up UniFi Protect device recovery codes from any NVR (Windows/Linux/macOS). By KCCS.
Extracts per-device recovery codes from your UniFi Protect NVR's backup file over local SSH and exports them to a CSV spreadsheet, so you are never locked out after a factory reset.
UniFi Protect is a video surveillance system made by Ubiquiti that runs on a dedicated device called an NVR (network video recorder). Every camera, bridge, light, speaker, and other device in that system has something called a recovery code: a per-device password that lives inside the NVR's nightly backup file. Most people never think about it until the moment a device needs a factory reset or they are moving to a new controller, at which point UniFi asks for the code and there is no obvious way to get it. Without the code, the device may not be adoptable again.
This tool exists to solve that problem before it becomes urgent. It connects to your NVR over an encrypted SSH connection, finds the most recent backup file the NVR created overnight, downloads it to your computer, and extracts the recovery code for every device into a single CSV spreadsheet. The whole process stays on your local network. Nothing is sent to any cloud service.
There are three ways to run it depending on what you have available. Windows users can double-click a batch file launcher that runs either a PowerShell-based graphical interface (no Python required) or a Python-based graphical interface. Both show a simple form where you type in your NVR's IP address, username, and password, then click two buttons. Mac and Linux users can run the Python GUI directly or use the command-line version, which accepts a backup file path and exports to text, CSV, or JSON.
The output CSV lists each device by type, name, model, MAC address, IP address, and recovery code. The README is clear that this file is effectively a password list and should be stored somewhere secure, not committed to version control or shared publicly. The repository's built-in ignore rules already block CSV files from being accidentally committed.
The tool was built by KCCS and is not affiliated with or endorsed by Ubiquiti.
Where it fits
- Run the tool before a planned device reset to export all UniFi Protect recovery codes to a CSV before you need them
- Recover adoption credentials after discovering a device needs its recovery code and you never saved it
- Use the CLI version on Mac or Linux to export recovery codes to JSON for integration with a password manager
- Store the exported CSV in a secure location as part of a UniFi network disaster-recovery documentation checklist