
Here is a reference design from Maxim how to built a circuit that would seamlessly switch to the secondary power supply if the primary fails.
This power-supply sequencer senses a loss of the main supply voltage and, by controlling the two FETs, automatically switches the load to the secondary (backup) supply.

Arduinos contain a simpler circuit that accomplishes roughly the same thing, using an op amp and a single MOSFET.
cant u just use 2 diode’s u will have a voltage drop but i use them for work using a bridge rectifier combine the negative terminals of the source’s and the load the positive terminal of the rectifier goes to load and the ac input’s of the rectifiers go to each of the power sources.
http://www.repeater-builder.com/astron/pdf/astron-rs-12a-bb.pdf this is a 12 volt battery backup power supply check out the top right corner it is the same thing with a resister to charge the battery