What's the easiest way to UCI backup/restore config?

Hello wizards,

I've been trying hard to migrate the configuration from a router to a new one, but stumbled on a problem I couldn't find a good answer to: assuming that UCI is "the right way" to do configs, how do I export the configs in a way that doesn't need much fumbling around to import in another router?

uci export shows configuration as files, and uci show show the UCI values but missing the needed uci add, add_list etc as well, so need checking line by line and also changing the array indexes to [-1] to make import easier, it's way too manual.

I want to use UCI as it's supposedly a bit better future proof and better for documenting. Also I want to audit my configs as I migrate, as there's a lot of cruft from years of upgrading.

Is there any way to export UCI config that makes for an easy import later? I don't want the raw config files.

Almost going the route of writing a script, but I'm sure this is a problem many should had solved already, I just couldn't find it...

Thanks lots!

You can use WinSCP or equivalent for your admin computer and copy/move the config files as you wish.

I would (have) used sysupgrade -b backup.tgz to create the backup contents, scp then untar it on another machine, change some of the config values as appropriate and then finally scp the results to the destination router.

sysupgrade will grab all the "backupable" files, which uci will not (it just deals with the config files), so if you have scripts or x.conf or whatever outside of /etc/config/, it will grab those, too. Run sysupgrade -l to list out the files that will be in the backup...

1 Like

That what I was trying to avoid... having the raw config files, as UCI should be a more friendly/portable interface for them... but realized not all config files are touched by UCI anyway, so moot point.

Things like the recent move to DSA, do they affect the syntax/structure of UCI files in /etc/config or only the program-specific configs?

Thanks!

Unless the routers are of the exactly same model and hardware revision, I wouldn't attempt to migrate neither /etc/config/network nor /etc/config/wireless. I'd still save the files from the old router and use them as reference (especially in the case of wireless which stores SSIDs/passwords), but I wouldn't blindly restore/copy these two files from the old router.

PS. if you're configuring things from CLI, it may be not a big task to create the uci-defaults script which can be included in the custom firmware and configure the router on the first boot.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.