Selecting only specific files to keep when sysupgrade

I have my custom image for the BPI-R4 setup using imagebuilder and a set of uci-defaults and other files.

Those configure the system exactly how I want it after the image has been flashed and booted.

Unfortunately, there are a couple of files I'd rather keep between updates to make my life easier.

Those are in particular the ssh hostkeys and allowed keys, as well as the wireguard keys and clients.

All the other configuration is replaced by the uci defaults, and I'd rather not "mix and match" keeping existing and possibly manually changed config files and the uci defaults from my config repo.

Now I noticed that sysupgrade doesn't just look at /etc/sysupgrade.conf but also a whole list of other config files based on different sources.

Is there a way to tell sysupgrade to explicitly only keep the files I tell it to? If not, would it make sense to create a patch / PR for that, or is that a feature that wouldn't make sense for most users?

My alternative idea currently is to backup the relevant files to my data partition on the eMMC, as it isn't touched by the sysupgrade. And hook that script somehow before a sysupgrade commences and read the results in my uci defaults.

Patch what? All backed up lists are in /lib/upgrade/keep.d/

Patch sysupgrade to support the behavior I described.

Unfortunately that is not the only source for sysupgrade. I looked at the code and it builds another list from the installed packages.

Nope, it is keep.d files installed by packages and sysupgrade.conf.

truncate a keep.d file you dont like and add its filename to sysupgrade.conf

You missed the list_changed_conffiles part. Because even after deleting everything in lib/keep.d/ you get a list of files from sysupgrade -l.

Hence my initial question if there is a flag to force sysupgrade to only consider /etc/sysupgrade.conf.

There is no flag.

Would it make sense to create a pull request to change that or is that a feature no one besides me would use and I should just patch it myself locally or use a workaround?

Power to you if you try. Would be nice to have some debug options to customize backup over sysupgrade (or config restore from luci).

I read about someone who tried this, but couldn't find it again. Not sure if it was here in the forums, or a GitHub PR or the mailing list.

Even had some Luci changes with a list picker for the files to restore from backup.

Luci integration would of course be great. If I could select the files to backup with sysupgrade upfront. Would have to look into all that code and how much effort it is. Never touched any of this code base.

There are instructions once you try to set up PR.

This is beside the point, but I've moved away from in-place upgrades entirely. Since the BPI-R4 can boot from an SD card, I build new firmware from source and put whatever extra files I need into the /files folder in buildroot. Then it's a matter of swapping SD cards with minimal resulting downtime, and every time there's a hot backup should something go wrong with the new build.