Difference between revisions of "Imapsync"

From SME Server
Jump to navigationJump to search
 
(16 intermediate revisions by 6 users not shown)
Line 14: Line 14:
  
 
=== Installation ===
 
=== Installation ===
==== Enable the dag repository ====
+
==== Enable the dag repository for SME 7====
{{Repository|dag}}
+
You need to activate the [[Dag]] reposity before installing this contrib.<br />
 +
 
 +
see [[dag|dag repository]] <br />
 +
==== Enable the epel repository for SME 8 after====
 +
For SME Server 8, 9 en 10  you can find imapsync in [[epel]], that version is most up to date
  
 
==== Install imapsync ====
 
==== Install imapsync ====
  yum --enablerepo=dag install perl-Mail-IMAPClient-2.2.9 imapsync
+
for SME7
 
+
  yum --enablerepo=dag install imapsync
'''IMPORTANT'''
+
or for sme8, sme9 en sme10
If you install imapsync without specifying perl-Mail-IMAPClient-'''2.2.9''' on the command line as shown above, yum will download and install the latest available version of perl-Mail-IMAPClient - currently 3.x - which does not work according to the author of imapsync.  If this happens, you will get an error about IMAPClient every time you run imapsync.
+
  yum --enablerepo=epel install imapsync
 
 
If you have accidentally installed the wrong version of IMAPClient, you can correct the problem using the command below.  When done, reinstall imapsync as shown above.
 
  yum remove perl-Mail-IMAPClient
 
  
 
=== Examples ===
 
=== Examples ===
 
==== Basic Example: Account Duplication ====
 
==== Basic Example: Account Duplication ====
 
This example would copy all existing folders from foo@imap.truc.org to bar@imap.trac.org
 
This example would copy all existing folders from foo@imap.truc.org to bar@imap.trac.org
  /usr/bin/imapsync \
+
  /usr/bin/imapsync --noauthmd5 \
 
   --host1 imap.truc.org --user1 foo --passfile1 /etc/secret1 \
 
   --host1 imap.truc.org --user1 foo --passfile1 /etc/secret1 \
 
   --host2 imap.trac.org --user2 bar --passfile2 /etc/secret2
 
   --host2 imap.trac.org --user2 bar --passfile2 /etc/secret2
Line 52: Line 53:
 
=====imapsync command=====
 
=====imapsync command=====
 
  <nowiki>/usr/bin/imapsync \
 
  <nowiki>/usr/bin/imapsync \
-- noauthmd5 \
+
  -- noauthmd5 \
--host1 a.b.c.d --port1 993 --ssl1 --user1 spamfilter --passfile1 /root/secret1 \
+
  --host1 a.b.c.d --port1 993 --ssl1 --user1 spamfilter --passfile1 /root/secret1 \
--delete --expunge1 --prefix1 "Public Folders." \
+
  --delete --expunge1 --prefix1 "Public Folders." \
--host2 localhost --port2 993 --ssl2 --user2 spamfilter --passfile2 /root/secret2 \
+
  --host2 localhost --port2 993 --ssl2 --user2 spamfilter --passfile2 /root/secret2 \
--folder "Public Folders/LearnAsSpam" \
+
  --folder "Public Folders/LearnAsSpam" \
--folder "Public Folders/LearnAsHam"  \
+
  --folder "Public Folders/LearnAsHam"  \
--noauthmd5 </nowiki>
+
  --noauthmd5 </nowiki>
  
 
====Migrating users and data to Zarafa====
 
====Migrating users and data to Zarafa====
Line 78: Line 79:
 
Perform a user mail sync from SME/IMAP (host1/port1) to Zarafa/IMAP (host2/port2)  
 
Perform a user mail sync from SME/IMAP (host1/port1) to Zarafa/IMAP (host2/port2)  
  
  imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 <username> --password1 <password> --sep2 / --prefix2 "" --host2 localhost --port2 8143 --split2 500 --user2 <username> --password2 <password>
+
  imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 <username> \
 +
  --password1 <password> --sep2 / --prefix2 "" --host2 localhost --port2 8143 \
 +
  --split2 500 --user2 <username> --password2 <password>
  
 
Example to synchronize a user named 'bob' with password 'bob123' from SME IMAP into Zarafa:
 
Example to synchronize a user named 'bob' with password 'bob123' from SME IMAP into Zarafa:
  
  imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 bob --password1 bob123 --sep2 / --prefix2 "" --host2 localhost --port2 8143 --split2 500 --user2 bob --password2 bob123
+
  imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 bob \
 +
  --password1 bob123 --sep2 / --prefix2 "" --host2 localhost --port2 8143 --split2 500 \
 +
  --user2 bob --password2 bob123
  
 
'''Note:''' If the synchronization process terminates, apparently successfully, but only part-way through, delete the dovecot.index.cache file in the last folder copied and restart the process. Adding "--useheader 'Message-ID' --skipsize" to the command above will prevent duplicates if the process does have to be restarted.
 
'''Note:''' If the synchronization process terminates, apparently successfully, but only part-way through, delete the dovecot.index.cache file in the last folder copied and restart the process. Adding "--useheader 'Message-ID' --skipsize" to the command above will prevent duplicates if the process does have to be restarted.

Latest revision as of 11:49, 24 February 2019

About

imapsync allows you to transfer or synchronize data between any two IMAP servers. This could be used in any of several scenarios:

  • Upgrading from one mail server to another (SME -> SME, Exchange -> SME, Notes -> SME)
  • Backing up email from one IMAP server to another
  • Automated spam learning when using SME with an internal mail server (see the Advanced example below).


Author: Gilles LAMIRAL <lamiral-at-linux-france.org>

Installation

Enable the dag repository for SME 7

You need to activate the Dag reposity before installing this contrib.

see dag repository

Enable the epel repository for SME 8 after

For SME Server 8, 9 en 10 you can find imapsync in epel, that version is most up to date

Install imapsync

for SME7

yum --enablerepo=dag install imapsync

or for sme8, sme9 en sme10

yum --enablerepo=epel install imapsync

Examples

Basic Example: Account Duplication

This example would copy all existing folders from foo@imap.truc.org to bar@imap.trac.org

/usr/bin/imapsync --noauthmd5 \
  --host1 imap.truc.org --user1 foo --passfile1 /etc/secret1 \
  --host2 imap.trac.org --user2 bar --passfile2 /etc/secret2

Bear in mind that you would need to create /etc/secret1 and /etc/secret2 containing the correct passwords for imapuser1 and imapuser2 respectively.

Advanced Example: Exchange Public Folders

This example will transfer the public folders 'LearnAsSpam' and 'LearnAsHam' from an Exchange server to the specified user on your SME server.

If you create and schedule a script to run this command regularly, and combine it with LearnAsSpam.pl and Auto-Learning you could let the users on an internal Exchange Server train your SME spamassassin by dragging SPAM or HAM into public folders in their Outlook.

Assumptions:

  • For the Exchange Server:
    • the user spamfilter exists on the Exchange server
    • the password for spamfilter on the Exchange server is in the file /root/secret1
    • the Exchange Server user spamfilter has Owner permissions on both Public Folders/LearnAsSpam and Public Folders/LearnAsHam
  • For the SME Server
    • the user spamfilter exists
    • the password for spamfilter on the SME server is in /root/secret2
    • the folders LearnAsSpam and LearnAsHam exist in the email root for spamfilter
imapsync command
/usr/bin/imapsync \
  -- noauthmd5 \
  --host1 a.b.c.d --port1 993 --ssl1 --user1 spamfilter --passfile1 /root/secret1 \
  --delete --expunge1 --prefix1 "Public Folders." \
  --host2 localhost --port2 993 --ssl2 --user2 spamfilter --passfile2 /root/secret2 \
  --folder "Public Folders/LearnAsSpam" \
  --folder "Public Folders/LearnAsHam"  \
  --noauthmd5 

Migrating users and data to Zarafa

Zarafa migration whitepaper describes various ways of migrating your users and your data to a Zarafa server.

http://download.zarafa.com/zarafa/release/docs/zarafa_migration.en.pdf

Folder Naming

SME and Zarafa use different folder naming. To enhance migration SME folders should be renamed prior to migration.

drafts > Drafts             
sent-mail > Sent Items
trash > Deleted Items
junkmail > Junk E-mail
IMAP migration from SME/IMAP to Zarafa/IMAP

By default smeserver-zarafa enables zarafa IMAP on port 8143

Perform a user mail sync from SME/IMAP (host1/port1) to Zarafa/IMAP (host2/port2)

imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 <username> \
  --password1 <password> --sep2 / --prefix2 "" --host2 localhost --port2 8143 \
  --split2 500 --user2 <username> --password2 <password>

Example to synchronize a user named 'bob' with password 'bob123' from SME IMAP into Zarafa:

imapsync --noauthmd5 --host1 localhost --port1 143 --split1 500 --user1 bob \
  --password1 bob123 --sep2 / --prefix2 "" --host2 localhost --port2 8143 --split2 500 \
  --user2 bob --password2 bob123

Note: If the synchronization process terminates, apparently successfully, but only part-way through, delete the dovecot.index.cache file in the last folder copied and restart the process. Adding "--useheader 'Message-ID' --skipsize" to the command above will prevent duplicates if the process does have to be restarted.