Gmail is a great thing, but if you want to keep an offline archive in the off chance that Google accidentally loses your email — or if you just like to have a separate archive offine — the easiest way to do this is to POP the email regularly.
Some use Thunderbird or other mailers for this, I find it easier to go ahead and use Fetchmail. To do this, just set up a .fetchmailrc which will live under your $HOME directory (i.e., /home/user) with something like the following:
set postmaster "USERNAME_LOCAL"
set bouncemail
set no spambounce
set properties ""
poll pop.gmail.com with proto POP3
user 'USERNAME_GMAIL' there with password 'PASSWORD' is 'USERNAME_LOCAL' here options keep ssl
For best results, run Fetchmail in daemon mode:
fetchmail -d 900
Replace the uppercase variables with the appropriate information. This assumes you’re using Fetchmail on a *nix system.
This will run Fetchmail every 15 minutes. It will take a while to sync up everything if you have a lot of mail in Gmail, so the best thing is to set this to run over night (or even over a weekend…) and check your mail spool after a day or two to see if you’ve got everything. Mail should be delivered to /var/spool/mail/username. You can use Mutt or something similar to read and archive from there.