How to backup your Ubiquiti devices using Oxidized.
I run Oxidized in a docker environment where I backup the configuration of Cisco, Dell, Ubiquiti and pfSense devices. This is what the config looks like and yes, these are not my actual credentials.
---
username: admin
password: password123
model: ios
resolve_dns: true
interval: 3600
use_syslog: false
log: /root/.config/oxidized/logs/log
debug: false
threads: 10
timeout: 20
retries: 0
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 0.0.0.0:8888
next_adds_job: false
vars: {}
groups: {}
models:
ย ios:
ย ย vars:
ย ย ย enable: calvin
ย pfsense:
ย ย username: oxidized
ย ย password: password123
ย powerconnect:
ย ย username: admin
ย ย password: password123
ย ย vars:
ย ย ย enable: calvin
pid: "/root/.config/oxidized/pid"
crash:
directory: "/root/.config/oxidized/crashes"
hostnames: false
stats:
ย history_size: 10
input:
ย default: ssh
ย debug: false
ย ssh:
ย ย secure: false
ย ftp:
ย ย passive: true
ย utf8_encoded: true
output:
ย default: git
ย file:
ย ย directory: "/root/.config/oxidized/gitrepo"
ย git:
ย ย user: Oxidized
ย ย email: oxidized@example.com
ย ย repo: "/root/.config/oxidized/gitrepo/"
source:
ย default: http
ย debug: false
ย http:
ย ย secure: false
ย ย scheme: https
ย ย url: https://librenms.example.com/api/v0/oxidized
ย ย map:
ย ย ย name: hostname
ย ย ย model: os
ย ย ย group: group
ย ย headers:
ย ย ย X-Auth-Token: <librenms-token>
model_map:
ย cisco: ios
ย juniper: junos
ย ubiquiti: airos, edgeswitch, unifi
ย pfsense: pfsense
What I noticed was that Oxidized didn’t like the banner that shows up ehen you ssh to a Ubiquity device, so I had to create a custom “unifi”-model and place it under a “model”-directory. My unifi.rb-file looks very much like the built in airos.rb model, exept the ” cmd 'clear' ” on row 5.
class Unifi < Oxidized::Model
ย # Ubiquiti 6.x
ย prompt /^[^#]+# /
ย comment '# '
ย cmd 'clear'
ย cmd 'cat /etc/board.info' do |cfg|
ย ย cfg.split("\n").map { |line| "# #{line}" }.join("\n") + "\n"
ย end
ย cmd 'cat /etc/version' do |cfg|
ย ย comment "airos version: #{cfg}"
ย end
ย cmd 'sort /tmp/system.cfg'
ย cmd :secret do |cfg|
ย ย cfg.gsub! /^(users\.\d+\.password|snmp\.community)=.+/, "# \\1=<hidden>"
ย cfg
ย end
ย cfg :ssh do
ย ย exec true
ย end
end
With this configuration I’m able to backup all of my Ubiquity devices, including access-points.