If your account is set up as IMAP, then everything will automatically be saved at the server level; if it gets deleted when you do the upgrade, it will automatically be copied down again to your computer.

Therefore, you could set up your account as IMAP, then move all email into the on-line folders. Or, as an alternative, you could set up a new email account as IMAP, and then move or copy all of your emails to that account's on-line folders; then after the upgrade, if your email got hosed on the computer, it will still be in the IMAP folders.