Right now to recover from a backup with an encrypted HD wallet the user must do something like unlock the wallet with a really long time out and manually trigger a rescan,  otherwise they risk missing some keys when auto-topup cannot run.
assert(new_db); // This is to prevent doing anything further with this . The original file was deleted, but a backup exists.
    m_databreset();
    m_database = stdmove(new_db);
    // Write existing records into the new DB
    batch = m_database->MakeBatch();
    bool began = batch->TxnBegin();
    assert(began); // This is a critical error, the new db could not be written to. The original db exists as a backup, but we should not continue execution.
    for (const auto& [key, value]  records) {
        DataStream ss_key{key};
        DataStream ss_value{value};
        if (!batch->Write(ss_key, ss_value)) {
            batch->TxnAbort();
            m_database->Close();
            fsremove(m_database->Filename());
            assert( // This is a critical error, the new db could not be written to. The original db exists as a backup, but we should not continue execution.
        }
    }
    bool committed = batch->TxnCommit();
    assert(committed); // This is a critical error, the new db could not be written to. The original db exists as a backup, but we should not continue execution.
    return true;
}
stdoptional<MigrationData> CWalletGetDescriptorsForLegacy(bilingual_str& error) const
{
    AssertLockHeld(cs_);
    LegacyScriptPubKeyMan* legacy_spkm = GetLegacyScriptPubKeyMan();
    assert(legacy_spkm);
    stdoptional<MigrationData> res = legacy_spkm->MigrateToDescriptor();
    if (res == stdnullopt) {
        error = _("Error Unable to produce s for this legacy . Make sure th is unlocked first");
        return stdnullopt;