The most simple backup source selector involves just two diodes

The problem with this kind of circuit is that there is always a voltage drop on the diode so the voltage that reaches the load is Vsupply - Vf
where Vf is the diode forward voltage drop.
Also the backup voltage should be lower than the main supply or both the diodes will be on simultaneously and both sources will share the output current.
A circuit that would work better (untested) would include the addition of a mosfet (it's a P-mosfet) that operates as a switch and connects/disconnects the battery depending on the availability of the main supply voltage.
Note that the main supply voltage shouldn't be higher than the max Vgs which is about 20v (check the datasheet of your specific device).
The battery voltage level is not a problem in this case, it can even be higher than the main voltage source.

Apart fro the mentioned solutions you can always design a circuit that involves a comparator and drives a switching device to connect he appropriate source or even use a commercial chip intended for supply monitoring.