You must be most specific. Each type of batteries requery a different charger (lead, NiCd, NiH,...)- Never the less for charging any kind of battery, at 6 V, you need a supply greater than 6V, your 5V will not work.
The most simple circuit to backup power is a relay (On when power is present and Off for battery power). My advise, and if you have space, is to use a lead battery, just supply a constant voltage at the terminal and its done.