BaGoMa is a python script that allows you to backup your GMail email account.
Because of some limitations google puts on IMAP transfers, it may take a few days to successfully back up an entire GMail account if it’s a large one. I had nearly 200,000 messages in my GMail account and it took almost a week of running the script daily (each run took a few hours) to get all the messages and attachments and labels properly downloaded (in daily chunks) and indexed. Though once done, the average daily backup update takes about 10 minutes.
It’s easy to throw the script into a cron job and have it run nightly. BaGoMa will also restore the backed up emails to ANY IMAP server, be it another GMail account or any email server on any domain that supports IMAP.
It works really well. I recommend you check it out.