Remotely pulling openWRT router's configuration

Hello. as part of a university project I wish to remotely pull all (or as much as possible) data relating to configuration, system, network, packages, etc. my first thought would be to make a script to pull this from the router via ssh.

is there a package or something else that is better suited for this functionality? if not, would all the information i need be in /etc/config? or is there usefull information elsewhere?

thanks

Config can be exported, through the gui, or pulled via ssh.

There is an option, on the web interface, to generate a full back-up of all the configuration files; this is probably a good starting point.

if I were to do this via ssh is all the information in /etc/config?

sysupgrade -b creates the backup file with all config included.

3 Likes

Keep in mind that exporting UCI settings and files provides only persistent configs, not runtime.
Here's the proper JSON RCP API for remote access and management over HTTP/HTTPS:

2 Likes

I do something like you want as my openwrt device backup routine .

#!/bin/bash
> Devices="device1 device2 device3"
> for Device in ${Devices}
>    do
>    ssh root@${Device} sysupgrade -b - > /Data/openwrts/${Device}-archive-$(/bin/date +%Y-%m-%d-%b-%s).tar.gz
>    done

This is run from a Linux box

4 Likes

Nice! I've been doing the ssh+backup into /tmp on the device, scp the file to my workstation, then ssh+rm on the backup. Time to go fix my backup script!

I have a backup.sh script that saves configs, and output from a bunch of run time commands. Then I do an scp command from the recipient host

scp root@192.168.1.1:/tmp/x/*   .

can ubus show me what devices are connected to the internet, via wan and wilreless?
ubus call network.device status or ubus call network.wireless status does not do this unfortunately

# dnsmasq leases
ubus call file read "{'path':'/tmp/dhcp.leases'}"

# odhcpd leases
ubus call dhcp ipv4leases
ubus call dhcp ipv6leases

# wireless clients
ubus call hostapd.wlan0 get_clients

# conntrack data
ubus call luci getConntrackList
1 Like