First, I'd double check that the battery is actually 5 V, close to it won't cut it and I can't think of any phone battery off the top of my head that is 5 V. Here's how I'd do it, assuming I had a Nokia 3310. Warning, involves hacking!
Basically, all Nokia phones charge off of 5--5.7V, and the batteries are 3.6 V Ni-Mh or Li-Ion batteries. First step hack a high current (at least 1 A) USB charger to also plug into the Nokia. This provides power of the Pi and to the charging circuitry of the phone. The positive battery terminal on the phone then need to be soldered to a 3.3 V Zener diode. The diode then connects to the 3.3V, and a second Zener connects the 3.3V to the 5V. When power cuts out, the Pi should keep going off the phone battery for a little bit, but all the peripherals would stop (including ethernet!) due to a lack of 5 V. Not an ideal solution but a clever little hack I think. More on running on 3.3 V.
It might be easier (if less fun) to go for a more ready solution. The MoPi project is billing itself as a UPS, although it currently doesn't provide any battery charging capabilities. It does have an enormous uptime though.