Australia fought back from the brink to defeat the Czech Republic and reach the Davis Cup semi-finals in Malaga.