Napoleon in Russia is the longest clear retreat.
Its the longest regular army retreat, at least 490 miles.
The Anabasis is considerably longer, but it is not corroborated.
There are a few massive countries like Canada or Australia, but they haven't had major wars on their territory. The only other countries to even approach that kind of length are China and India, neither of which seem to have any notable retreats across their length - besides insurgencies like the Long March, as the other answer has already found.
List of Chinese wars and battles
List of Indian battles
You could also consider situations like the defeat of the Africa Korps to be a retreat, but it was more of a delaying action and doesn't clearly qualify. The reason why Napoleons' retreat was unique was, firstly, because his army was much larger and better supplied than medieval and ancient militaries, and secondly because Russia was late to industrialize and did not have the logistical ability to pursue him. This is an unusual combination that does not happen often.