Offlineimap - a utility, used to synchronize between IMAP servers and Maildir style mailboxes on Unix systems, is very convenient. It can be used to back up your mail, stored on a remote IMAP server. Unfortunately, some releases of the utility are quite buggy - the latest version from the previous maintainer was simply broken, refusing to connect to many remote servers. It appears, however, that there is a new maintainer for the project. The GIT repository can be found here. Caveat emptor.