How To Backup Gmail With getmail Tool

December 15, 2013 | By
| Reply More

All my life 'depends' on my gmail account. I email my friends, contact people i want to know or work with, send documents and stay updated with the latest blogs. Now, imagine what will happen if i forget my username or password and lose my gmail account. All my contacts, information and documents will be gone!

What to do? I know a nice command line tool that can help me and you. It is called getmail, a tool that can retrieve messages from POP3, IMAP4, and SDPS mailboxes.

Use the following command to search for getmail tool.

sudo apt-get cache search getmail

How To Backup Your Gmail With getmail Tool

Install the getmail tool.

sudo apt-get install getmail4

After the getmail tool is installed we need to create a directory for storing the mbox file. Run the following command to create the .getmail directory in your home directory.

mkdir ~/.getmail

Where are we going to store our emails? We need to create another directory, run the following command to create the gmail-archive directory inside the home directory. Make sure you are in the home directory.

mkdir ~/gmail-archive

Note: The directory we created with the above command will store your email.

Change directory with the following command.

cd ~/.getmail

how to backup gmail in ubuntu

Now create the file with the following command.


Paste the following text.

type = SimplePOP3SSLRetriever
server =
username =
password = bobpassword

type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox

# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/.getmail/gmail.log

how to backup gmail in ubuntu

Go under destination and edit the file like shown below.

type = Maildir
path = ~/gmail-archive/

Run the following command to make the three directories used by the Maildir format.

mkdir ~/gmail-archive/tmp ~/gmail-archive/new ~/gmail-archive/cur

how to backup gmail in linux

Open the config file again and under retriever add your username and your password. Then run the following command to backup your gmail.

getmail -r ~/.getmail/

how to backup gmail in linux


Tagged With :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.