Switching circuit or relay
This seems to be as simple as powering a relay from the AC line.  Many relays will be available with coils intended for you AC line voltage and frequency.

The relay is then a switch that is thrown one way when there is AC power, and the other way when there isn't.  Generally these relays will be at least SPDT (single pole double throw).  That means there is a common contact that is switched to be connected to one of two other contact.  The three leads are often referred to as COM (common), NO (normally open), and NC (normally closed).

Put the COM and NC leads of the relay in series with the 12 V battery.  That switch will be on when there is no power applied to the relay coil, and off when there is.

Make sure that the relay contacts are rated for the maximum current everything you connect to the battery could draw.