Buy an Uninterruptible Power Supply
When your power goes out suddenly, bad things happen to desktop computers. Any changes to files you were using are lost in an instant. Worse, the fast-spinning platter inside your hard drive and the magnetic head that reads data from it can collide, potentially damaging the disk. This isn't a problem for laptop users, since there's a battery inside to keep powering the machine if the lights go out. If you have a desktop computer then you'll definitely want to purchase an uninterruptible power supply (UPS.)
A UPS is a great big battery for desktop computers. You leave the UPS plugged in to the wall, continuously charging, and your computer plugged into the UPS. Not only does this protect against power failures, it also keeps power spikes and brownouts from hurting your equipment.
The tricky part is figuring out what size UPS you need. You want to plug the computer and monitor (not the printer, which is a power hog and unnecessary in a blackout) into a battery-backed outlet, but different computers and monitors draw different amounts of power. If you look at your computer and monitor manuals, or the manufacturers' online sites, you should find the power draw figures in volts (VA) and watts (W). With this information, you can visit UPS manufacturers' websites or read product boxes at a retail store and figure out which units will meet your needs.
As an alternative, if you know what kind of processor your computer uses and the monitor size, you can calculate a recommendation at the web site of APC, a leading manufacturer in this category (you're not locked into their product line, since the results provide the recommended power capacity in addition to specific APC model names). As you'd expect, their calculation will err on the high side, but that's not the worst thing — having more power available never hurts while not having enough is big trouble, and even beefy UPS system for home users are available for around $100. Also, some UPS systems come with software that will automatically and safely shut down your computer in case of a blackout, a very useful feature.