Connecting two sources of power

Hi! I want to connect my arduino to the main power supply via a 12V power and also to have a 9V battery connected as an emergency power source if there is a power shutdown of the electric grid. I connected the battery to the Vin and GND pins, does the arduino recognise when one of the sources is unavailable?

Thanks!

no. simplest way: use 2 diodes (schottky)