All you need is a relay. It has to "accept" 220-230V as the input and needs to be able to handle 12V or whatever on the output. It also needs to be "normally closed". Normally closed means when the input is "dead" ie. theres no electricity in this case, the output circuit will be closed. When there is electricity, ie. 220V on the input side, the switch will be open so the pump will be off and the battery can charge.