Monday, October 25, 2010

Migrate / Backup your mails to gmail / google apps.

Hi All...

Here are some worked examples on how to do the synchronization to google hosted email system.

Step 1.
 Create directory to where you can store password files.

Step 2.
Make a list of password files. (A password file is one with only the password stored in it)

Step 3.
Check the version of imap-sync using in your computer. The synchronization works only with versions above 1.261. If you are using debian / ubuntu use the below command to check the version.

apt-cache policy imapsync
imapsync:
Installed: 1.286+dfsg-3ubuntu1
Candidate: 1.286+dfsg-3ubuntu1

Step 4.
After the installation of imapsync go to the password created directory.

Step 5.
To synchronize the mail from any domain to gmail OR google hosted apps use the following command. (Make sure imap has been enabled in the Gmail account)

$ imapsync --host1 mail.domain.com --user1 source@domain.com --noauthmd5 --passfile1 /path/to/passwordfile --host2 imap.gmail.com --user2 destination@domain.com --passfile2 /path/to/passwordfile --port2 993 --ssl2 --folder 'INBOX' 'INBOX.Sent'

Step 6.
If the given credentials are correct, the command will look like the following.


with perl 5.10.1
Mail::IMAPClient  3.21
IO::Socket        1.31
IO::Socket::SSL
Digest::MD5       2.39
Digest::HMAC_MD5
Term::ReadKey     2.30
Date::Manip
with perl 5.10.1Mail::IMAPClient  3.21IO::Socket        1.31IO::Socket::SSL   Digest::MD5       2.39Digest::HMAC_MD5 Term::ReadKey     2.30Date::Manip

/usr/bin/imapsync --host1 mail.domain.com --user1 source@domain.com --noauthmd5 --passfile1 passwordfile --host2 imap.gmail.com --user2 source@domain.com --passfile2 passwordfile --port2 993 --ssl2 --folder INBOX INBOX.Sent
Turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
TimeZone:[asia/kolkata]
Will try to use LOGIN authentication on host1
Will try to use LOGIN authentication on host2
From imap server [mail.domain.com] port [143] user [source@domain.com]
To   imap server [imap.gmail.com] port [993] user [source@domain.com]
Banner: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE
THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE STARTTLS] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc.  See COPYING for distribution information.


Host mail.domain.com says it has NO CAPABILITY for AUTHENTICATE LOGIN
Success login on [mail.domain.com] with user [source@domain.com] auth [LOGIN]
Success login on [mail.domain.com] with user [source@domain.com] auth [LOGIN]
Banner: * OK Gimap ready for requests from 12 x26if996498wfd.20
Host imap.gmail.com says it has NO CAPABILITY for AUTHENTICATE LOGIN
Success login on [imap.gmail.com] with user [source@domain.com] auth [LOGIN]
host1: state Authenticated
host2: state Authenticated
From separator and prefix: [.][INBOX.]
To   separator and prefix: [/][]
++++ Calculating sizes ++++
From Folder [INBOX]                             Size:  11375813 Messages:    34
Total size: 11375813
Total messages: 34
Time: 15 s
++++ Calculating sizes ++++
To   Folder [INBOX]                             Size:      5626 Messages:     2
Total size: 5626
Total messages: 2
Time: 2 s
++++ Listing folders ++++
From folders list: [INBOX]
To   folders list: [Follow up] [INBOX] [Misc] [Priority] [[Gmail]] [[Gmail]/All Mail] [[Gmail]/Drafts] [[Gmail]/Sent Mail] [[Gmail]/Spam] [[Gmail]/Starred] [[Gmail]/Trash]
++++ Looping on each folder ++++
From Folder [INBOX]
To   Folder [INBOX]
++++ From [INBOX] Parse 1 ++++
++++ To   [INBOX] Parse 1 ++++
++++ Verifying [INBOX] -> [INBOX] ++++
Time: 4 s
++++ End looping on each folder ++++
++++ Statistics ++++
Time                   : 20 sec
Messages transferred   : 0
Messages skipped       : 0
Total bytes transferred: 0
Total bytes skipped    : 0
Total bytes error      : 0
Detected 0 errors

Step 7.
Check your mail box to see if the mails have been synchronized.

Happy Migrating...

No comments: