Got Your Back (GYB) is a command line tool for backing up your Gmail messages to your local computer. It uses the standard IMAP protocol but also takes advantage of some custom Gmail IMAP extensions.
Here’s how I used it to move all my email messages from one gmail account to another one.
Download it from here:
https://github.com/jay0lee/got-your-back
Put it in your home folder in a filder called gyb.
From terminal:
cd ~/gyb
python gyb.py --email wayne@dubbo.org --action estimate
tells you what it will do
python gyb.py --email wayne@dubbo.org --action backup
backs it all up, mine took 8GB
python gyb.py --email wayneconnor@dubbo.org --action restore --local-folder GYB-GMail-Backup-wayne@dubbo.org --label-restored "old"
restores it from backup to a different google account  and puts a label on it all called ‘old’
It’s been updated:
bash <(curl -s -S -L https://gyb-shortn.jaylee.us/gyb-install)
get sit going then the above commands.