Power distribution switch for auxiliary battery
If you use a micro-controller make sure your software is able to react pretty fast in order to switch from mains to battery.
I did that in the past and I never had problems.
Bulk capacitors on the +3V supply bus are able to keep alive your micro-controller for a minimum of 10 ms, depending on the board design.
As a power mux you may use two pnp 60V MOSFET's in parallel. In this case you will have to use 2 output pins of your micro-controller to turn selectively on the 2 MOSFET's.
https://www.digikey.com/en/products/detail/vishay-siliconix/SIHFR9024TR-GE3/10641179