Some themes save the recent sidebar widgets settings amongst other theme settings in wp_options as theme_mods_mynewtheme (assuming mynewtheme is your new theme folder name).
If you lost some settings (including widget settings), you can copy/paste the option_value contents of theme_mods_myoldtheme into theme_mods_mynewtheme. That may help or at least restore some theme settings. However, that might not restore your sidebar settings (theme-specific case, not general).
In general, if you haven’t re-activated your theme under Appearance > Themes, you can save your old sidebar_settings first and re-insert them in the database after you reactivated your new theme:
SELECT * FROM wp_options where option_name="sidebars_widgets"
- Copy the entire contents of option_value
- Re-activate your theme under Appearance > Themes
- Refresh the query from step 1
- Paste what you copied from step 2 into option_value
Edit: In case you don’t have database access, you can programatically (somehow ugly approach) use the functions get_option and update_option to do the above. You can use maybe_serialize to serialize what you get from get_option and pass using maybe_unserialize to update_option.