Automatic switching to battery on mains failure?

Oh, and more bonus points if the solution includes an obvious way for the Arduino to determine which power source it's running on (so it can sound an alarm when it switches to the battery).

I guess what I'm looking for is a small-capacity DC UPS.