mysqldumper will do the trick for you. its a beasty script.