https://cirrus-ci.com/task/5603470202896384?logs=ci#L2681
// Make a backup of the DB
    stdstring _name = ->GetName();
    fspath this__dir = fsabsolute(fsPathFromString(->GetDatabase().Filename())).parent_path();
    fspath backup_filename = fsPathFromString(strprintf("%s-%d.legacy.bak", _name, GetTime()));
    fspath backup_path = this__dir / backup_filename;
    if (!->BackupWallet(fsPathToString(backup_path))) {
        return utilError{_("Error Unable to make a backup of your ")};
    }
    res.backup_path = backup_path;
    // Unload th so that nothing else tries to use it while we're changing it
    if (!RemoveWallet(context, , /*load_on_st, warnings)) {
        return utilError{_("Unable to unload th before migrating")};
    }
    UnloadWallet(stdmove());
    // Load th but only in the context of this function.
    // No signals should be connected nor should anything else be aware of this 
    WalletContext empty_context;
    empty_context.args = context.args;
    DatabaseOptions options;
    options.require_existing = true;
    DatabaseStatus status;
    stdunique_ptr<WalletDatabase> database = MakeWalletDatabase(_name, options, status, error);
    if (!database) {
        return utilError{Untranslated("Wallet file verification failed.") + Untranslated(" ") + error};
    }
    stdshared_ptr<CWallet> local_ = CWalletCreate(empty_context, _name, stdmove(database), options.create_flags, error, warnings);
    if (!local_) {
        return utilError{Untranslated("Wallet loading failed.") + Untranslated(" ") + error};
    }
    bool success = false;