Usually, people don't try to unplug a desktop PC when it's running. Desktop PCs are not meant to be portable, so there are no battery-driven power supplies for them. You might be able to jerry-rig a car battery into a full-tower, but you'd have to convert the 12V DC power into mains-equivalent 120V AC that your computer's PSU can then transform back into 12V and 5V, 3.3V, etc.
However, if you just want your computer to stay on during a blackout, then you can simply buy a UPS unit. Your computer still has to be plugged into the UPS, and most consumer-grade UPSs don't offer much more than 5-15 minutes of on-battery time, but it's usually enough to save your documents and power down safely. And like surge protectors, you're usually insured up to $X for damages if the UPS fails and your equipment is damaged.
For more sustained off-grid usage, people usually rely on emergency power systems. These are backup generators that automatically kick in when the regular mains power is down. These systems can either run on gasoline or diesel and can be sustained indefinitely as long as you don't run out of fuel. They can be used to keep the lights on in your entire building, or they can be used to supply power only to select devices/outlets (e.g. in many hospitals, they have color-coded outlets so that life-critical machinery can be kept on when there's an outage).