This circuit is permanently plugged into a mains socket and NI-CD batteries are trickle-charged. When a power outage occurs, the lamp automatically illuminates. Instead of illuminating a lamp, an alarm sounder can be chosen. When power supply is restored, the lamp or the alarm is switched-off. A switch provides a "latch-up" function, in order to extend lamp or alarm operation even when power is restored.
Mains voltage is reduced to about 12V DC at C2's terminals, by means of the reactance of C1 and the diode bridge (D1-D4). This avoids the use of a mains transformer. Trickle-charging current for the battery B1 is provided by the series resistor R3, D5 and the green LED D6 that also monitors the presence of mains supply and correct battery charging. Q2 & Q3 form a self-latching pair that start operating when a power outage occurs. In this case, Q1 biasing becomes positive, so this transistor turns on the self latching pair. If SW3 is set as shown in the circuit diagram, the lamp illuminates via SW2, which is normally closed; if set the other way, a square wave audio frequency generator formed by Q4, Q5 and related components is activated, driving the loudspeaker. If SW1 is left open, when mains supply is restored the lamp or the alarm continue to operate. They can be disabled by opening the main on-off switch SW2. If SW1 is closed, restoration of the mains supply terminates lamp or alarm operation, by applying a positive bias to the Base of Q2.
circuit from http://www.extremecircuits.net/2009/07/emergency-light-and-alarm.html