How to keep the existing config even if the default is changed

How can we keep the existing config values, even if their default values are changed?
I know ConfD changes the config values to new default values during upgrade according to their new default values. But, we want to keep some config values even if their default values are changed at the new software, and use the new default values for new config only. How can we achieve this by the easiest way? I checked ConfD manual, and found MAAPI and upgrade() function, but are there any easier ways than them?

Best regards and thanks in advance.

Another option I can think of, apart from full upgrade scenario, is to save the configuration (or parts of it, or individual leaves) with default values, and load it after restart. But that is obviously usable only if you have good control over when data model upgrade is done and over the system startup.

Hi mvf,
Thank you for your comment and trying to help me; Yes, your idea needs to implement upgrade() function, and I’d like to avoid a big change…
By the way, I tried to implement a validate() callback:

  1. old software has an old default value,
  2. new software has a new default value ans a validate() callback, which returns CONFD_ERR during upgrade(phase < 2).
    But, look like, validate() callback wasn’t called during upgrade(phase < 2), and this could not achieve keeping the old default value in config.
    I will try to test a transaction-hook next, but, if anyone knows any good option or why validate() callback isn’t called during upgrade(phase < 2), I would greatly appreciate any.
    Best regards and thanks in advance.