Skip to content

restore_config

Restore controller state from a backup_config envelope.

Side effects:

  • Diffs the envelope against current controller state and applies an ordered create/delete plan. Deletes run first (firewall_rules, port_forwards, wlans, dhcp_leases, port_profiles, networks); creates run second in the reverse order. No update path in this version: drifted fields show up as a delete + create pair (or stay put when names match).
  • Cross-controller restore: if the envelope’s controller differs from the target, the restore proceeds and the response includes a warning.
  • Stripped secrets: if secrets_stripped: true, every restored WLAN whose x_passphrase still equals the sentinel is forced to enabled=False so a known-string SSID is never broadcast. The operator must reset each passphrase and re-enable manually.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
  • Rollback: if any sub-step fails, all prior creates are reverted in reverse order and the response includes partial and rolled_back keys. Deletes that already ran are NOT undone (no copy was kept); the response reports them so the operator can re-run with dry_run to inspect the residual gap.

Schema validation: schema != "1" returns an error envelope and no action is taken.

restore_config(backup_json=snapshot, dry_run=True)
ParameterTypeRequiredDefaultDescription
backup_jsonstringyesThe envelope JSON string from backup_config.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.