Creating system snapshots to use as backups

I have been using OpenWrt for a few months and really like the system, but I haven't really planned things too well and have just got stuck into things.

I'm currently using OpenWrt 21.02.0-rc2 r16122-c2139eef27

I'd like to upgrade to the stable release version, but I'm worried I might break something.

I have a spare micro SD card, so I can create a fresh install and start fresh with the option of switching back to my current setup.

I would like to achieve the following. Is it possible?

  • Fresh install of stable build.
  • Get basics setup (e.g. interfaces, VLANs, Luci, etc).
  • Create a snapshot (e.g. .tar file that can be used to create a new SD card) and store it on my PC.
  • Install packages (e.g. Adblock) and create snapshots as I go.
  • Once I'm happy with the 'final' configuration, I'd like to create a snapshot for easy system restoration.
  • Ideally, I'd like to schedule a snapshot schedule, so that I can easily restore my system if I ever break it or suffer an SD card failure.
  • I may buy another Raspberry Pi 4 as a backup, so that it can be easily swapped out in an emergency or can be used as a test bed for experimental configuration.

What do you think?

I'm still slightly confused by the use of packages/updates. The advice is to never update packages because it can mess with stability, does that mean that all packages have to be installed on day one because they may not be compatible in a month's time?

afaik this isn't supported natively (OpenWrt itself can't do these snapshots), afaik only some Linux OS for PC and the Turris Omnia router (which is running a modified OpenWrt) can do this.

Afaik the best you can do this by just unplugging the SD card from the device, plugging it to your PC and doing a raw disk image every time you want a "snapshot". Then you can compress it as a zip or anything else to shrink it down massively (as a raw disk file is as big as your SD card, but all free space in the image compresses down to nearly nothing if run through a compression algorithm, since most of it is free space).
You can use simple tools like this https://www.osforensics.com/tools/write-usb-images.html

If you want to restore it, you write it raw again on the sd card.

There are more advanced backup software that can also be used to do something like this.

In theory, you should be able to update all packages without issues, if we talk about stable releases.
The issue with package updates was that in the past there have been some core package updates that would not install correctly in a running system and the only way forward was to do a "firmware upgrade" procedure, where you upgrade the whole OS at once and install a new base OS image with updated packages.

In general, if it's packages you install yourself then you can freely update them. If you see updates for packages you did not install (or that are not libraries or dependencies of stuff you installed), then it's probably better to do a firmware upgrade instead.

1 Like

Thanks for taking the time to reply.

In terms of getting from 'RC2' to 'stable', what are the risks of applying the upgrade file? Does it overwrite configuration files - e.g. DNS HTTPS Proxy, etc?

every time you do a firmware upgrade you will lose installed packages (that are not in default image) but all configuration is saved (unless you chose to also reset to default, this is an option in the firmware upgrade popup), so you only need to install the packages again afterwards. https://openwrt.org/docs/guide-quick-start/sysupgrade.luci

there is a package that should deal with this automatically, as long as the device can access the Internet without the packages you install https://openwrt.org/docs/guide-user/troubleshooting/backup_restore#preserving_packages

1 Like

I think a lot of my config was done via the CLI - e.g. DoH with Dnsmasq and https-dns-proxy.

Will that configuration be lost?

One thing you can do is download a backup of the system configuration, unzip it and have a look at what is included.

configuration files in /etc/config (used by UCI commandline and Luci to configure applications that have been integrated with OpenWrt config management) and usually the config files of packages you install are backed up (the packages usually add a file somewhere to request their non-standard config backup). see all the locations from here https://openwrt.org/docs/guide-user/troubleshooting/backup_restore#default_backup_settings

You can try and see if your config is backed up already by generating a backup archive and downloading it to your PC. Then you can just open it with linux archive managers or 7Zip on Windows and see if your data is there.

If not, you need to add your custom script or configuration file (with full path, so /etc/myconfig.conf) in the /etc/sysupgrade.conf file

1 Like