You can do this, and EM Fields answer is correct as far as it goes.
But be aware that whichever source has the higher voltage will supply most of the current. This means that the battery cannot be charged to a higher voltage than the adapter. This will prevent giving it a full charge. This site indicates that the minimum voltage for charging should be more than 12 volts, although something near 12 will probably work to give a partial charge at a very slow rate. Even if you use an externally charged battery, a lead-acid maintained at 12 volts will not have anywhere near full charge. Here, for instance is a chart which suggests that if your battery is only allowed 12 volts it will only have about 50% charge.
That's not to say you can't do it and get something that sort of works (and may even be adequate to your needs), it's just that you'll need to do some experimenting and may be disappointed with the results.
Diode steering is much better used when the primary voltage is somewhat higher than the backup voltage. If possible, something like a 15 volt supply and a 12 volt battery would be a better match.
EDIT - The idea of using an Arduino to detect a power dropout and switch in a battery is certainly possible, but you can do it automatically.
simulate this circuit – Schematic created using CircuitLab
Here, if the supply is active the relay is pulled in and the output is about 11 volts. If the supply is interrupted the relay opens and selects the battery.
This has a number of features. Most importantly, the relay is not a 12 volt relay. The problem with a 12 volt relay is that it will not release until the voltage across the coil gets quite low - sometimes as low as 15% of the nominal voltage. With a 5 volt relay and 7 volt zener, the relay will drop out at a much higher voltage, decreasing the period of low voltage associated with the switchover.
The capacitor is quite large and depends on both the load current and the relay speed. The higher the current and the slower the relay, the larger the capacitor should be.
The diode allows for the possibility of a fast turnoff of the supply by preventing the cap from discharging back to the supply before the relay releases.
The biggest problem with this setup is the current surge associated with changing states. This can damage the relay contacts, so use a relay with considerably larger current rating than your load current.