Monday, April 22, 2013

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.

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.

On the Authenticate dialog box, enter your password and click 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.

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.

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.

Select Save As to save your configuration file.

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.

Close gedit, or whatever text editor you used.

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

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.

You now have an mbox file containing your Gmail messages.

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.

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.

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.

No comments:

Post a Comment