There are "DIY emergency back-up power supply" plans on the net. They use a deep cycle battery, power inverter, relay, and battery charger. And yes they do automatically switch over from AC to DC when the power gets cut-off. Hell of alot cheaper then a UPS, and you get the same pros.
just remember to use a true sine wave inverter