August 04, 2011

How to back up your gmail on ubuntu

Quick-and-dirty solution:

1. install python and getmail
2. make a getmail config like this:

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = your_user_name@gmail.com
password = your_password

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

[options]
# 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 

3. enable pop on your gmail account
4. add a cronjob like this:

13,33,53 * * * * /usr/bin/getmail -q -r /path/to/your/getmail/config

You’ll end up with a .mbox file which grows and grows over time. Mine is currently at 5GB. I have no idea whether thunderbird or evolution can open such a big file, but mutt can (use “mutt -f ~/gmail-archive/gmail-backup.mbox -R” , unless you really like waiting whilst mutt rewrites the mbox on each save) , or it’s easy enough to grep through if you just need to find the text of a specific message. If you needed to break it into chunks, you could always just use split, and accept that you’ll lose a message where the split occurs (or use split, and then patch toghether the message that gets split in half.


- 4 comments by 2 or more people Not publicly viewable

  1. Mike Willis

    How to back up your gmail on ubuntu Linux.

    FTFY ;)

    11 Aug 2011, 15:30

  2. sonia

    There are five basic functions that we all need to perform in order to manage and safeguard our email- backup, restore, archive, transfer and organize the data. Beyond Inbox can help you perform all of these in a very efficient and easy way.It generate separate file(.eml) for each email message.
    Beyond Inbox is available in two different flavors i.e. an easy User Interface using which you use all its feature like backup ,restore,copy and move and Command line interface using which you can schedule the task of gmail backup or IMAP backup .
    You can use this tool on Windows, Linux as well as Mac OSX. Click here to download beyondinbox.com/beyondinbox-download.html

    17 Oct 2011, 05:51

  3. Sam

    Hi, when I download all the emails in my inbox gets Mark Red. Is it possible that the ones which I have mark unread remain unread. Please let me know. Thanks!

    12 Nov 2011, 06:10

  4. Chris May

    If you’re using this script (or another POP client) to download your messages and Gmail is marking them as read, then you need to go to the settings page from gmail (click on the cog in the top right), then click on “forwarding and pop/imap”.
    In the “POP download” section, there’s a dropdown that specifies what to do when messages are accessed via POP. Make sure that’s set to “Keep GMails copy in the inbox”, not “Mark as read”. HTH :-)

    22 Nov 2011, 13:15


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Most recent entries

Loading…

Search this blog

on twitter...


    Tags

    Not signed in
    Sign in

    Powered by BlogBuilder
    © MMXIX