battery backup supply switch over design
The most simple solution is to simply Diode-OR both supplies like this:







simulate this circuit &ndash; Schematic created using CircuitLab

The downside is that you'll drop 0.7V across a regular silicon diode and about 0.15-0.2V across a Schottky, which may or may not be acceptable to you.

If you want something a little more complex, but will actually turn off any supply from the battery (and probably have less voltage drop when the battery is connected):







simulate this circuit

The FET should be some sort of low-RDSon FET.
Either way you will still need some sort of power conditioning circuit, like a buck-boost so that you can accept voltages higher and lower than your required output voltage. These circuits take care of the power source arbitration.