summaryrefslogtreecommitdiff
path: root/wired/old/published/How To Wiki/howtobackupgmail.txt
blob: 7107af08279fb101e0877d82578d6f5e09fdf515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Web-based e-mail services like Gmail, Yahoo Mail or Windows Live Mail are great for their access-anywhere capabilities -- all you need to check your mail is a browser.

Many even prefer the web-based interface to a desktop client -- it's one less application to have running and, in case of Gmail, the search capabilities and conversation threading blow desktop apps out of the water.

However, using a service like Gmail means you don't have a local backup of your e-mail as you would get if you were checking it with a desktop client. 

Naturally that doesn't mean you can't get a backup of your e-mail stored locally and still enjoy and goodness of Gmail's web interface.

== Backup Using a Desktop Client ==

Just because you're using the web interface doesn't mean you can't use a desktop client to make backups. All the major operating systems ship with a built in e-mail client. Some are better than others, but all of them can connect to your Gmail account and download your messages to create a local copy.

Beware that some of these apps may store mail in funky proprietary formats (Apple Mail, Outlook, we're looking at you here) rather than industry standard formats like .mbox. To guarantee cross platform compatibility, we recommend Mozilla's [http://www.mozilla.com/en-US/thunderbird/ Thunderbird 2.0]. Thunderbird 2.0 even offers a handy one-click set up for accessing Gmail. 

The first thing you need to do is head to the Gmail web interface and click the settings link at the top right corner of the page. Look for the "Forwarding and POP/IMAP" tab and click the link.

Now you need to enable either POP or IMAP. For most people POP will work just fine and it's the simpler of the two. Just select the "Enable POP for all mail" option. In step two you'll notice that you can control what Gmail does when your desktop client connects under the "When messages are accessed with POP" setting. Choose "keep Gmail's copy in the Inbox" since we're just using POP for backup purposes.

Now startup Thunderbird, enter your username (the bit before @gmail.com in your e-mail address) and password and Thunderbird will begin downloading your e-mail, creating a local backup. There's no need to mess with Thunderbird's settings or since you're just doing this for backup purposes.

While this method will work and is definitely the easiest for most people, there are some drawbacks. The most obvious is your sent mail, which isn't included. And you have to remember to open Thunderbird periodically so that your mail gets backed up. If you're looking for a way to automate the backup process and don't mind a little command line tinkering, read on.

== Backup Gmail using Getmail ==

Getmail is an open source Python program that can backup your Gmail account. [http://pyropus.ca/software/getmail/ Getmail] will work on any *nix system, including OS X, and even Windows as long as you have [http://cygwin.com/ Cygwin] installed. 

=== Installing Getmail ===

Ubuntu users have it easy since Getmail is in the Ubuntu repositories

For other systems you can either add the repository to aptitude or you can compile from the source like so:

Download Getmail, then open a terminal windows and type:

<code>tar xzvf getmail*.tar.gz
cd (the directory that was created)
sudo python setup.py install</code>

=== Setting up Getmail ===

Now you just need a configuration file to tell Getmail how to connect to Gmail. There are a ton of [http://pyropus.ca/software/getmail/getmailrc-examples sample configuration files] on the Getmail site, but here's one that works well with Gmail. Create a file at ~/.getmail/getmail.gmail and put the following text in it:
<code>
    [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 
</code>

Getmail won't create the mbox file, so before we get started create a new empty file, gmail-archive.mbox in the gmail-archive folder of your home directory (or where ever you choose to store it). From the command line this will do the trick: <code>touch ~/gmail-archive/gmail-backup.mbox<code>

=== Running Getmail ===

Okay we have everything set up, time to actually make our backup. Fire up a terminal window and enter the following line:

getmail -r ~/.getmail/getmail.gmail

You should see a long string of messages begin printing out as Getmail starts grabbing the contents of your Gmail account. If the script stops fear not, Google has some limits on how many messages can be retrieved at one time. Just run the above command again the Getmail will pick up where it left off.

Now you have an mbox formatted local backup of your Gmail account and you can access it with any e-mail client that understands mbox files (pretty much everything except Outlook).

To automate this process just create a shell script and attach it to a cron job that runs once a day, or however often you feel is necessary.


== Backup Using Fetchmail ==

Backing up using Fetchmail is probably the most difficult and arcane option of the bunch, but if you're looking for a weekend project and enjoy tinkering with the command line, Fetchmail can create backups of your Gmail account.

Have a read through the Fetchmail documentation to see how you need to set things up and then check out Lifehacker's [http://lifehacker.com/software/gmail/geek-to-live--back-up-gmail-with-fetchmail-235207.php tutorial on Fetchmail]. It's written for Windows users running Fetchmail under Cygwin, so if you're on a *nix system just ignore the Cygwin-specific elements.