Using/Charging a backup battery in a 12VDC circuit
This is more of a comment than an answer because your requirements are made fuzzy by your illogical (don't take it to heart) circuit:

Are you looking for this type of basic configuration of your batteries: -



If so, then add the relay contact either in series with the 12V battery or in series with Vout. I'm assuming that your arduino will always take power from one of the supplies. I guess you'll need some kind of charge circuit for the 12V to keep it topped up too. This can be done with a schottky diode in series with a resistor from 13.8V directly to 12V BUT it depends on your battery type and I'm no expert on battery chargers.