I remember a couple of years ago i migrated my mailboxes to a new machine when i upgraded my hardware.
I don't know the exact steps anymore, but the steps outlined at the following article looks similar and may be helpful:
Although i haven't tried this myself yet, this tool also looks interesting:
As i'm currently also trying to figure out how to upgrade from 5.2 to 6.x i will probably use one of above.
If i really have enough time to perform the upgrade i will post the results here.