如何使用imapsync在IMAP服务器之间迁移邮箱
版本1.0
作者:Falko Timme
本指南介绍如何使用imapsync在IMAP服务器之间迁移邮箱 。 imapsync是一个IMAP同步,同步,复制或迁移工具。 成功支持超过32种不同的IMAP服务器软件。 所有标志都保留,未读将保持未读,读取将保持读取,删除将保持删除。
我不会保证这将为您工作!
1初步说明
我在这里使用两个Debian或Ubuntu服务器(程序对于其他发行版应该是一样的,只有imapsync的安装会有所不同):
-
server1.example.com
(来源) -
server2.example.com
(目标)
我想将server1.example.com上
的邮箱sales@example.com
(username: sales@example.com
,password: secret
) 迁移
到server2.example.com
上的邮箱sales@example.com
(用户名和密码是与server1.example.com
相同)。
2我们开始之前
在我们开始之前,让我们来看看这两个邮箱,看看它们的内容(你可以使用电子邮件客户端,如Outlook,Thunderbird或基于Web的电子邮件客户端,如SquirrelMail - 我在这里使用SquirrelMail)。
server1.example.com:
server2.example.com:
迁移后,server1.example.com上的两条消息应在server2.example.com上可用
。
3 imapsync安装
如果我们在server1.example.com
或server2.example.com上安装imapsync,我们甚至可以将其安装在第三个无关的服务器上。
aptitude install imapsync
要了解其用法,请查看
man imapsync
和
imapsync --help
4进行迁移
我们必须告诉imapsync我们要迁移的邮件帐户的用户名和密码。 理论上,我们可以使用--password1
和--password2
开关的密码,但这是危险的,因为密码会出现在
ps aux
(所以任何被允许运行该命令的用户都知道密码。)
因此,最好在包含密码的两个文件( / etc / secret1
和/ etc / secret2)
中创建这两个文件(在这个例子中,这是两个邮件帐户的秘密
),对这些文件执行chmod 600
,然后使用- -passfile1
和--passfile2
开关。
echo "secret" > /etc/secret1
echo "secret" > /etc/secret2
chmod 600 /etc/secret1
chmod 600 /etc/secret2
现在我们可以使用这个简单的命令进行迁移:
imapsync --host1 server1.example.com --user1 sales@example.com --passfile1 /etc/secret2 --host2 server2.example.com --user2 sales@example.com --passfile2 /etc/secret2
以下是一个示例输出:
root@server1:~# imapsync --host1 server1.example.com --user1 sales@example.com --passfile1 /etc/secret2
--host2 server2.example.com --user2 sales@example.com --passfile2 /etc/secret2
$RCSfile: imapsync,v $ $Revision: 1.252 $ $Date: 2008/05/08 02:30:17 $
Here is a [linux] system (Linux server1.example.com 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64)
with perl 5.10.0 and the module Mail::IMAPClient version used here is 2.2.9
Command line used :
/usr/bin/imapsync --host1 server1.example.com --user1 sales@example.com --passfile1 /etc/secret2
--host2 server2.example.com --user2 sales@example.com --passfile2 /etc/secret2
Turned ON syncinternaldates, will set the internal dates on host2 same as host1.
TimeZone :[CEST]
Will try to use CRAM-MD5 authentication on host1
Will try to use CRAM-MD5 authentication on host2
From imap server [server1.example.com] port [143] user [sales@example.com]
To imap server [server2.example.com] port [143] user [sales@example.com]
Banner : * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA
IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information.
Host server1.example.com says it has NO CAPABILITY for AUTHENTICATE CRAM-MD5
Error login : [server1.example.com] with user [sales@example.com] auth [CRAM-MD5]: 3 NO Login failed.
Trying LOGIN Auth mechanism on [server1.example.com] with user [sales@example.com]
Success login on [server1.example.com] with user [sales@example.com] auth [CRAM-MD5]
Banner : * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA
IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information.
Host server2.example.com says it has NO CAPABILITY for AUTHENTICATE CRAM-MD5
Error login : [server2.example.com] with user [sales@example.com] auth [CRAM-MD5]: 3 NO Login failed.
Trying LOGIN Auth mechanism on [server2.example.com] with user [sales@example.com]
Success login on [server2.example.com] with user [sales@example.com] auth [CRAM-MD5]
From capability : QUOTA STARTTLS NAMESPACE IDLE THREAD=ORDEREDSUBJECT ACL SORT UIDPLUS CHILDREN ACL2=UNION IMAP4REV1 THREAD=REFERENCES
To capability : QUOTA STARTTLS NAMESPACE IDLE THREAD=ORDEREDSUBJECT ACL SORT UIDPLUS CHILDREN ACL2=UNION IMAP4REV1 THREAD=REFERENCES
From state Authenticated
To state Authenticated
From separator and prefix : [.][INBOX.]
To separator and prefix : [.][INBOX.]
++++ Calculating sizes ++++
From Folder [INBOX] Size: 2412 Messages: 2
From Folder [INBOX.Drafts] Size: 0 Messages: 0
From Folder [INBOX.Sent] Size: 0 Messages: 0
From Folder [INBOX.Trash] Size: 0 Messages: 0
Total size: 2412
Total messages: 2
Time : 11 s
++++ Calculating sizes ++++
To Folder [INBOX] Size: 16844 Messages: 6
To Folder [INBOX.Drafts] Size: 0 Messages: 0
To Folder [INBOX.Sent] Size: 0 Messages: 0
To Folder [INBOX.Trash] Size: 0 Messages: 0
Total size: 16844
Total messages: 6
Time : 0 s
++++ Listing folders ++++
From folders list : [INBOX] [INBOX.Drafts] [INBOX.Sent] [INBOX.Trash]
To folders list : [INBOX] [INBOX.Drafts] [INBOX.Sent] [INBOX.Trash]
++++ Looping on each folder ++++
From Folder [INBOX]
To Folder [INBOX]
++++ From [INBOX] Parse 1 ++++
++++ To [INBOX] Parse 1 ++++
++++ Verifying [INBOX] -> [INBOX] ++++
+ NO msg #1 [FID6mR7SVC7csdmRce+7PQ:924] in INBOX
+ Copying msg #1:924 to folder INBOX
flags from : [\Seen]["26-May-2009 22:00:59 +0200"]
Copied msg id [1] to folder INBOX msg id [7]
+ NO msg #2 [4lu3SCjZGH2mRuiP1dY7Mw:1488] in INBOX
+ Copying msg #2:1488 to folder INBOX
flags from : [()]["27-May-2009 14:12:59 +0200"]
Copied msg id [2] to folder INBOX msg id [8]
Time : 0 s
From Folder [INBOX.Drafts]
To Folder [INBOX.Drafts]
++++ From [INBOX.Drafts] Parse 1 ++++
++++ To [INBOX.Drafts] Parse 1 ++++
++++ Verifying [INBOX.Drafts] -> [INBOX.Drafts] ++++
Time : 0 s
From Folder [INBOX.Sent]
To Folder [INBOX.Sent]
++++ From [INBOX.Sent] Parse 1 ++++
++++ To [INBOX.Sent] Parse 1 ++++
++++ Verifying [INBOX.Sent] -> [INBOX.Sent] ++++
Time : 0 s
From Folder [INBOX.Trash]
To Folder [INBOX.Trash]
++++ From [INBOX.Trash] Parse 1 ++++
++++ To [INBOX.Trash] Parse 1 ++++
++++ Verifying [INBOX.Trash] -> [INBOX.Trash] ++++
Time : 1 s
++++ Statistics ++++
Time : 12 sec
Messages transferred : 2
Messages skipped : 0
Total bytes transferred: 2412
Total bytes skipped : 0
Total bytes error : 0
Detected 0 errors
Please, rate imapsync at http://freshmeat.net/projects/imapsync/
?Happy with this free, open source and gratis GPL software?
Feel free to thank the author by giving him a book:
http://www.amazon.com/gp/registry/wishlist/1C9UNDIH3P7R7/
(or its paypal account gilles.lamiral@laposte.net)
root@server1:~#
之后我们可以删除两个密码文件:
rm -f /etc/secret1
rm -f /etc/secret2
在目标服务器( server2.example.com
)上,注销您的IMAP帐户并重新登录(一个简单的刷新可能还不够),您应该看到来自server1.example.com
的消息:
server2.example.com:
5链接
- imapsync: http : //www.linux-france.org/prj/imapsync/