Common solution would be an Uninterruptible Power Supply (UPS) These have power conditioners and battery packs that protect computers from unexpected power loss. They are intended only for a system to have enough power to gracefully shut down, though. One that can run a computer for several hours twice a day is going to cost more than your typical computer. (and the modem/router, monitor for that matter)
You can take a UPS that has 12V lead acid batteries and add a large parallel bank of deep cycle batteries. Again quite expensive. Semi truck batteries can be used in a pinch.
Only other solution would be a standard UPS to run your computer, and a whole house generator or power wall that can kick in a few seconds after a power failure.