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.