Design IC backup with supercapacitor
Linear Technologies offers the LTC4041, which seems to provide exactly what you're looking for, automatic switching between a main power and a backup power source. It looks like it supports both Li-ion and supercaps. 

http://www.analog.com/en/products/LTC4041.html#product-overview

The LTC4041 is a complete supercapacitor backup system for 2.9V to 5.5V supply rails. It contains a high current step-down DC/DC converter to charge a single supercapacitor or two supercapacitors in series. When input power is unavailable, the step-down regulator operates in reverse as a step-up regulator to backup the system output from the supercapacitor(s).