SEARCH

How-To Geek

How to Backup Your Gmail Account Using Your Ubuntu PC

00_lead_image_getmail

We always hear how important it is to backup your data, but do we think about backing up our web-based email? We have shown you how to backup your Gmail account using programs in Windows, but what if you are using Linux?

In Windows, you can use GMVault or Thunderbird to backup your Gmail account. You can use Thunderbird in Linux as well, but there iss also a program for Linux called Getmail that will backup your Gmail account to a single mbox file. Getmail works in any Linux distribution. Ubuntu users can easily install Getmail using the Ubuntu Software Center. For other Linux operating systems, download Getmail, and then refer to the installation instructions on the website.

We will show you how to install and use Getmail in Ubuntu. Open the Ubuntu Software Center using the icon on the Unity bar.

00a_starting_ubuntu_software_center

Type “getmail” (without the quotes) in the Search box. The results display as you enter the search term. Select the “Mail retriever” result and click Install.

01_clicking_install_for_getmail

On the Authenticate dialog box, enter your password and click Authenticate.

02_authenticate

Once the installation finishes, exit the Ubuntu Software Center by selecting Close from the File menu. You can also click the X button on the title bar.

03_closing_software_center

Before using Getmail, you need to create a configuration directory, a directory to store the mbox file, and the mbox file itself. To do this, open a Terminal window by pressing Ctrl + Alt + T. At the prompt, type the following command to create the default configuration directory.

mkdir –m 0700 $HOME/.getmail

To create a directory for the mbox file that will be filled with your Gmail messages, type the following command. We called our directory “gmail-archive” but you can call the directory what you want.

mkdir –m 0700 $HOME/gmail-archive

Now, you must create the mbox file to contain the downloaded messages. Getmail does not do this automatically. Type the following command at the prompt to create the mbox file in the gmail-archive directory.

touch ~/gmail-archive/gmail-backup.mbox

NOTE: Both “$HOME” and “~” refer to your home directory at /home/<your name>.

Leave this Terminal window open. You will use it later to run Getmail.

04_creating_folders_and_mbox_file

Now, you need to create the configuration file to tell Getmail about your Gmail account. Open a text editor, such as gedit, and copy the following text into a file.

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = yourname@gmail.com
password = yourpassword
[destination]
type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox
[options]
verbose = 2
message_log = ~/.getmail/gmail.log

Change the username and password to the ones for your Gmail account. If you used a different directory and filename for the mbox file, change the “path” in the “destination” section to reflect your path and filename.

05_creating_config_file

Select Save As to save your configuration file.

06_selecting_save_as_gedit

Enter “.getmail/getmailrc” (without the quotes) in the Name edit box to save the file as the default “getmailrc” file in the configuration directory you created and click Save.

07_saving_config_file

Close gedit, or whatever text editor you used.

08_closing_gedit

To run Getmail, go back to the Terminal window and type “getmail” (without the quotes) at the prompt.

09_running_getmail

You’ll see a long string of messages display in the Terminal window as Getmail starts downloading the contents of your Gmail account.

NOTE: If the script stops, don’t panic. Google has some limits on how many messages can be downloaded from an account at one time. To continue downloading your messages, just run the Getmail command again and Getmail will pick up where it left off. See Getmail’s FAQs for more information about this issue.

When Getmail finishes and you are returned to the prompt, you can close the Terminal window by typing exit at the prompt, selecting Close Window from the File menu, or clicking the X button on the title bar.

10_closing_terminal_window

You now have an mbox file containing your Gmail messages.

11_mbox_file

You can import the mbox file into most email clients, except Microsoft Outlook. For example, you can use the ImportExportTools add-on in Thunderbird to import your Gmail messages from your mbox file into a local folder.

12_import_mbox_file_in_thunderbird

If you need to get your Gmail messages into Outlook in Windows, you can use the free MBox Email Extractor program to convert your mbox file to separate .eml files that you can import into Outlook.

13_mbox_email_extractor

You can automate the process of backing up your Gmail account by creating a shell script and setting it to run on a schedule using a cron job that runs once a day, once a week, or however often you feel is necessary.

For more information about using Getmail, see their documentation.

Lori Kaufman is a freelance technical writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 02/28/13

Enter Your Email Here to Get Access for Free:

Go check your email!