The Gmail account is retrievable from the server at any time. About the On My Mac mails, you will need a good Mac Mail backup software. I have been using Mail Backup X for the same. Take a free trial of this tool (it comes for 15 days as free). Hope that helps you backup the Mac Mail message.
for a quicker search:http://www.mailbackupx.com/how-to-scenerios/how-to-backup-apple-mac-mail-mails-on-mac.html