I have used a UPS (Uninterruptable Power Supply) for many, many years on my main computer. They do die of course, but instead of buying a brand new one when they stop working, just replace the battery! It is not that difficult.
A UPS generally has several plugs that are used for surge protection. They always have a few plugs that are not only surge protected but are connected to a battery backup inside the device. The idea is if the power goes out or even flickers the battery kicks in and whatever is connected to it will continue to run. If it is a computer (most often it is) you will have time to save your work and shutdown the computer properly.
In my case, I have my iMac, my main production machine, and a couple of small peripherals connect to the battery side of my belkon 750 VA UPS. I have not had to use the battery function too often, but when you need it, it is really handy. When the power goes off and the battery kicks in the UPS beeps so you know to get to your computer and do what you have to do.
Most fairly expensive UPS devices have a way to replace the battery. My Belkin unit costs about $90-100 to replace, so just replacing the battery for about $40 is a no brainer. If you are sure the rest of the unit is still working properly then by all means replace the battery and you are good to go for a couple of years at least.
Here is my Belkin unit:
The plugs nearest the bottom are connected to the UPS. On this model the battery is removed from the back:
You just open that back panel, pull out the battery and disconnect the two wires. In my case I took the battery with me (the best way really) to a local Batteries Plus. Showed them the old battery and they gave me this new one:
Duracell? Really? Hey, whatever works is fine with me. Once I got home I installed the new battery in the Belkin:
You just push it back in the slot, put the cover on and plut it in to AC. After turning it on I reconnected all the devices.
If you don’t have a UPS device on your computer I higly recommend getting one. They really are great protection.