Switch power supply/battery
Assuming you can live with a certain amount of slop in your output, you don't need a transistor. 







simulate this circuit &ndash; Schematic created using CircuitLab

Consider if the battery is missing. Then depending on the load current, the output will be in the range of 12 to 12.5 volts (Schottky diodes have lower forward drop than standard diodes). Is this OK? If so,

Consider what happens when the battery is inserted. As long as the battery voltage is below 12.5 volts, it will not provide any current. If the battery is above 12.5 it will provide current at a higher voltage, but only until it has discharged to below 12.5.

Note that the diodes must be rated for the load currents you need. Also be aware that, if you short the load to ground accidentally, you're in trouble. The 12 volt supply will current limit at some (presumably) reasonable level, but batteries are not reasonable.