Here are the instructions for Messages and Gmail.
Backing up Gmail / Any or All of your Google Products Data
Google Takeout: The simplest of the backup snapshot offerings is the one provided by Google: Google Takeout. From your Google settings, you can export just about all of your Google data, across all your Google applications. Google Takeout dumps the data either into your Google Drive or lets you download a pile of ZIP files. It's easy, comprehensive, and free.
Create an archive with your data from any or all of your Google products. https://takeout.google.com/settings/takeout
Locate your Messages archive
- In the Messages app, go to Messages > Preferences.
- Check the "Save history when conversations are closed" box.
- In the Finder, head to the Go menu and select Go to Folder.
You should see two folders: Archive and Attachments along with a file database labeled "chat.db".
Archive holds all your past messages from conversations that you've closed or saved; Attachments holds all the images and video from those conversations. The chat.db holds all the information from your active message history.
Archived conversations are labeled pretty clearly: They're all in folders labeled by date closed, and individual files give you the name of the participant along with the date and time. Open one, and you'll see the conversation pop up in Messages.
You can't edit, search, or export conversations to a different format, but you can copy and paste sentences and load it through the Messages App while having an archive.