Get a UPS. A small one will keep you up and running for about 10 minutes or so depending on the load.
I have a UPS in my office for the computer, but not for the Internet connection which is in another room. It stays on long enough to save files and do an orderly shutdown.