Tip: I periodically copy gmail and more seldomly used iCloud mail from the cloud to Mail.app's Local folder in ~/Library/Mail. Select desired messages and via right-click > Copy (or Move) to the Local mailbox:


Periodically maybe once a year I zip and backup that (usually hidden) ~/Library/Mail folder or transfer it to another Mac or new macOS: Mail > File > Import Mailboxes... > Apple Mail > choose ~/Library/Mail folder > choose all Items. Then on the left-hand-side under "On My Mac" > Import, ..., look for and move "Local" and all mailboxes inside it up under "On My Mac". Right-click and delete "Import" Mailbox (it has gmail mailboxes that are online), YMMV.