How do I design a device to automatically switch to the backup battery?
If all you want is a hot-swappable power supply and you have a bit of leeway for your inputs, you can connect backup battery to the anode of a diode, and connect the cathode to your main