Will the pump work if the mains supply goes off and the Apex is also offline? How did you get the 0-5v to the pump using the battery backup? I have tried a similar setup with DPDT relay, but had difficulty getting the 0-5v to the pump, when on battery backup alone.
simple voltage regulator will do the trick. 12 or 24 volt battery feeds the pump and regulator feeds the control line with either 3 or 5 volts to make it simple.....
or powering the stock controller input directly from the battery, with relay switching from the psu over to battery, which then provides the voltage to controll the speed of the pump.
Either works depending on what you needs are.