Maintain arduino timer value

Hello.. I am working on an project that needs the internal timer to be set all the time, even if the arduino it's not powered. The project is specifically a domotic project that executes certains alarms (using the Time.h library), and the arduino it's going to be inside the wall, powered with the common 220v using a 220v-5v switching power supply. If the building's power is gone, the arduino doesn't power on and also the time setted inside is gone.

The arduino internal time can be set any time at runtime with a BlueTooth connection with an Android.

I know that I can implement an external circuit and use an external timer using other IC powered with a battery, but I want to know if this can be done directly with the arduino, maintaining the power given to the internal timer using a battery directly on some arduino pins.

thanks!

How long to you want the Arduino to run in the event of a mains power outage?

One solution might be to run the Arduino off a 6v Lead-Acid battery and have a mains trickle charger to keep the battery full.

...R

Thanks for the answer Robin, it may be a solution.. but its not acceptable because the arduino must be inside the light box in the wall (sorry for my english) and I need to keep it the smallest I can. A battery increments the size of the proyect.

My first idea was try to keep the timer running like any motherboard does: the bios powered by a battery, but I needed to know if its possible to do the same directly to the arduino, powering it directly to some pins.

If its not possible, I need to use an external circuit to keep track of the system time.

Thanks!

Can you provide any form of network connectivity? If so, you can look up the time over the network rather than rely on a persistent local clock source.