How to save OpenWrt settings

I am reading up on how to back up and restore OpenWrt settings and finding out that it is a complex process that involves your "choosing" what to include and some items being "left out" by design.

See for example:

That seems rather less good than what is available even on a "regular" router, where you might get a button for "SAVE" config. Press it, decide the name of the config file and the target path, click OK, and you're done. No "choosing" on your part, and nothing "left out." If your router settings get wiped out on a power surge, all you have to do is "RESTORE" that one config file.

Or if you say that changes on OpenWrt include packages (install/remove) as well as settings, computers can be "cloned" with Clonezilla, Ghost, Acronis True Image, etc., where again you don't have to "choose" anything and nothing gets "left out."

Let us say that a method for backing up and restoring is "straightforward" if you don't have to choose anything and nothing gets left out, as per examples above.

Question: Is there a "straightforward" way to back up and restore an OpenWrt router?

Just to be sure, here's one consequence of backing up and restoring a device in a "straightforward" way: If you back up a device on July 4 in a straightforward way and later restore it that way, you can be absolutely sure that the device has been restored to the state it was in on July 4. Nothing was left out, nothing changed.

I would like the answer to say either yes there is a straightforward way to back up and restore an OpenWrt router, or no there is not. If yes, I would like to be told how.

If no, then I would be quite happy to be told, as second best, to go somewhere and "choose everything you see" if you don't know what you're doing. (Which would involve "choosing," but at least result in the certainty of restoration to the July 4th state, as it were.)

If you connect and mount a USB thumb drive to your router (with required USB mount packages installed), you can automate backups using the same mechanism the GUI provides.

Then add an entry to the schedule tasks and restart the cron process

My script will not save any installed packages, but you can modify to add what others have done

VERSION=`grep DISTRIB_RELEASE /etc/openwrt_release | cut -d "'" -f 2`

sysupgrade -b /mnt/sda1/backup-${HOSTNAME}-$VERSION-$(date +%F).tar.gz

find /mnt/sda1/backup-*.tar.gz -mtime +365 -exec rm {} \;

Thanks. Implicit in your answer seems to be the idea that there is no straightforward way to back up an OpenWrt router that leaves out nothing. Is that right? The process doesn't have to run on its own. I don't mind manual or time consuming so long as the result is completeness so that, upon restoration, there is nothing left for me to do and I got my "old router as was."

If you have not installed any extra packages, then getting the backup file from Luci is pretty straight-forward. Same for restoring it.

If you have installed extra packages, then you need to make sure that their configuration files are included in the backup. If the configuration files exist in /etc/config/ then they are included. If not, then verify and include them. In either case, upon restoring the router from defaults, you'll need to reinstall the packages and restore the backup.

It's the same as the first case I explained. Otherwise show us a "regular" router with such a package list as OpenWrt has.

1 Like

OK. That's fair. Can you then "clone" the whole device? Using Clonezilla type software. Otherwise,this reinstalling of additional packages, and presumably redeleting of what you had deleted, recreating additional user accounts, etc. now begin to look like rebuilding a system.

i use imagebuilder with files and package option, with a script on my linux desktop i rsync all my configuration, including ssh keys, passwords, all package settings and so to my files/ folder.. the result is a fully working image with my known good configuration 100% good to go, including all packages and settings, ready to be flashed at any time or after some testing gone bad a factory reset will reset to my 100% working factory settings.. this is also a very fast way to upgrade to minor release es. 19.07.7 to 19.07.8 i don't even bother to keep settings since all is already in my image.. just my 2 cents here :wink:


Great. This looks more like what I'm looking for. Except it doesn't sound like building "from" the router, as in, "Okay, this is the router I want. Back it up to an image file." Rather it sounds like "building an image the same way you built the router you wanted." If so, as your router progresses, you have to do parallel things to your image (so they are synced). Am I on the right track?

yep, just need to work on your "sync script" to save all your configs at first and keep your imagebuilder command updated with all extra package you use.. remember to fire your "sync script" when you modify something, run imagebuilder and you will end up doing a "restore my router to a ready to go flashable image file" instead of a "backup that needs to be restored post standard installation". your "sync script" will be the key point of the workflow so take your time to check if it contains all you need.. a few flashing test of the first image you generate are recommended :wink:


Just to make sure I understood, would workflow look like this? I (a) decide to work my router this after noon > (b) turn on rsync (the "sync script") > (c) work on the router > (d) thanks to rsync, see a verbatim copy of the router configurations appear on my Linux desktop > (e) run imagebuilder > (f) use the verbatim copy as component of the new image?

I'm sorry I've never done this before, obviously. But at stage (f), do I have to remember to include user (i.e. by me) installed packages (as components of the new image)? For example, if I installed OpenSSH, do I repeat picking OpenSSH as component every time I build an image? Or is there a facility for "starting where you left off," that is, starting from the immediate predecessor image that's already got e.g. OpenSSH. In this case, I suppose you still have to remember what packages you installed or removed since the creation of that predecessor image. Is any of this right?

Depending on the router, yes you can. To take it one step further if you have a router with removable storage card, e.g RPi, you can keep a backup sd card and just swap it to have the router up and running.


you first modify what you need on your router and then copy/sync changes to your local imagebuilder files folder so next time you generate an image you have an updated working image.

for packages you just need to add them to the package option (every time all packages name you need) and imagebuilder will do the magic and add them to your image, you just keep track of extra packages in a text file for example (the imagebuilder command will be in your terminal history anyways :wink:)

you should not bother to much of the build technichal matters, imagebuilder will take care of all.. if you want to bother go for a full build evoirment and have fun :smiley:


Thanks very much! Your detailed guidance gave me a good idea of what I may have to do. I am choosing trendy's comment on cloning as "solution" as it most directly responds to the original post.

The "block-level backup/restore via [CLI]," as linked in your comments, is exactly what I originally wanted (and more, as regard RPi). But since everyone, including yourself, seems to recommend the config method, I believe I will start with that. Thanks.

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