This commit is contained in:
Nick Bebout 2011-03-12 02:44:20 +00:00
parent 00a0bc81fd
commit ab8d0b0cf7
8 changed files with 167 additions and 44 deletions

11
CREDITS
View file

@ -1,10 +1,17 @@
#!/bin/cat #!/bin/cat
Sven Havemann
Moved from Braunschweig to Graz and asked
how to move Braunschweig mail sorted into
a folder INBOX.Braunschweig
See FAQ.
Vincent Deffontaines Vincent Deffontaines
Made me talk about --exclude 'fold1|fold2|f3' Made me talk about --exclude 'fold1|fold2|f3'
Jim Rosenberg Jim Rosenberg
Had problems with dbmail. Had problems with dbmail 2.0.7.
Gave up too early with bad feedback :-)
Thomas Stegbauer Thomas Stegbauer
Suggested the mailing list creation. Suggested the mailing list creation.
@ -15,7 +22,7 @@ Made me wrote the learn/subscribe script example.
René Pfeiffer René Pfeiffer
Paid me 100 euros for just an imapsync success story Paid me 100 euros for just an imapsync success story
and little help from me. René also wrote a LinuxGazette and little help from me. René also wrote a LinuxGazette
article about imapsync in april/may 2006 article about imapsync in march 2006
Mike Mike
Gave "Mdaemon 8.1" success story. Gave "Mdaemon 8.1" success story.

View file

@ -1,17 +1,29 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.149 head: 1.152
branch: branch:
locks: strict locks: strict
gilles: 1.149
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 149; selected revisions: 149 total revisions: 152; selected revisions: 152
description: description:
---------------------------- ----------------------------
revision 1.149 locked by: gilles; revision 1.152
date: 2006/02/17 02:57:21; author: gilles; state: Exp; lines: +55 -18
Made the --justconnect a real "just connect" connection,
not a auth connection like it is now.
----------------------------
revision 1.151
date: 2006/02/17 01:28:57; author: gilles; state: Exp; lines: +9 -6
Added documentation about --regextrans2, dry mode.
----------------------------
revision 1.150
date: 2006/02/16 05:23:05; author: gilles; state: Exp; lines: +9 -7
DBMail 2.0.7 failure story
----------------------------
revision 1.149
date: 2006/02/14 00:44:44; author: gilles; state: Exp; lines: +9 -8 date: 2006/02/14 00:44:44; author: gilles; state: Exp; lines: +9 -8
Documented --exclude 'fold1|fold2|f3' Documented --exclude 'fold1|fold2|f3'
---------------------------- ----------------------------

32
FAQ
View file

@ -44,6 +44,38 @@ b) Use stunnel
then use imapsync on localhost (or bar machine) imap (143) port. then use imapsync on localhost (or bar machine) imap (143) port.
======================================================================
Q. I have moved from Braunschweig to Graz, so I would like to have my whole
Braunschweig mail sorted into a folder INBOX.Braunschweig of my new mail
account.
R.
1) First try (safe mode):
imapsync \
...
--regextrans2 's/INBOX(.*)/INBOX.Braunschweig$1/' \
--dry --justfolders
2) See if the output says everything you want imapsync to do,
--dry option is safe and does nothing real.
3) Remove --dry
Check the imap folder tree on the target side
4) Remove --justfolders
=======================================================================
Q. Give examples about --regextrans2
R. Examples:
1) To remove INBOX. in the name of destination folders:
--regextrans2 's/^INBOX\.(.+)/$1/'
2) To sync a complete account in a subfolder called FOO:
--regextrans2 's/^INBOX(.*)/INBOX.FOO$1/'
======================================================================= =======================================================================
Q. I'm migrating from WU to Cyrus, and the mail folders are Q. I'm migrating from WU to Cyrus, and the mail folders are
under /home/user/mail but the tool copies everything in under /home/user/mail but the tool copies everything in

16
README
View file

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration. mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.149 $ $Revision: 1.152 $
INSTALL INSTALL
imapsync works fine under any Unix OS. imapsync works fine under any Unix OS.
@ -39,7 +39,7 @@ SYNOPSIS
[--regextrans2 <regex> --regextrans2 <regex> ...] [--regextrans2 <regex> --regextrans2 <regex> ...]
[--sep1 <char>] [--sep1 <char>]
[--sep2 <char>] [--sep2 <char>]
[--justfolders] [--justconnect] [--justfolders] [--justfoldersizes] [--justconnect]
[--syncinternaldates] [--syncinternaldates]
[--buffersize <int>] [--buffersize <int>]
[--syncacls] [--syncacls]
@ -167,9 +167,11 @@ BUGS
Report any bugs to the author: lamiral@linux-france.org Report any bugs to the author: lamiral@linux-france.org
IMAP SERVERS IMAP SERVERS
Failure story reported with the following imap server : Failure stories reported with the following imap servers :
- MailEnable 1.54 (Proprietary) http://www.mailenable.com/ - MailEnable 1.54 (Proprietary) http://www.mailenable.com/
- DBMail 2.0.7 (GPL). But DBMail 1.2.1 works.
Patient and confident testers are welcome.
Success stories reported with the following imap servers (softwares Success stories reported with the following imap servers (softwares
names are in alphabetic order) : names are in alphabetic order) :
@ -182,7 +184,7 @@ IMAP SERVERS
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.1.18 - Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.1.18
2.2.1, 2.2.2-BETA, 2.2.10, 2.2.12, 2.3-alpha (OSI Approved) 2.2.1, 2.2.2-BETA, 2.2.10, 2.2.12, 2.3-alpha (OSI Approved)
(http://asg.web.cmu.edu/cyrus/) (http://asg.web.cmu.edu/cyrus/)
- DBMail 1.2.1 (GPL) (http://www.dbmail.org/) - DBMail 1.2.1 (GPL) (http://www.dbmail.org/). 2.0.7 seems buggy.
- Dovecot 0.99.10.4 0.99.14 (LGPL) (http://www.dovecot.org/) - Dovecot 0.99.10.4 0.99.14 (LGPL) (http://www.dovecot.org/)
- Domino (Notes) 6.5, 5.0.6, 5.0.7 - Domino (Notes) 6.5, 5.0.6, 5.0.7
- Groupwise IMAP (Novell). Buggy so see the FAQ. - Groupwise IMAP (Novell). Buggy so see the FAQ.
@ -210,7 +212,9 @@ IMAP SERVERS
From software :* OK louloutte Cyrus IMAP4 v1.5.19 server ready From software :* OK louloutte Cyrus IMAP4 v1.5.19 server ready
To software :* OK Courier-IMAP ready To software :* OK Courier-IMAP ready
You can use option --justconnect to get those lines. You can use option --justconnect to get those lines. Example :
imapsync --host1 imap.troc.org --host2 imap.trac.org --justconnect
And please rate imapsync at http://freshmeat.net/projects/imapsync/ And please rate imapsync at http://freshmeat.net/projects/imapsync/
@ -263,5 +267,5 @@ AUTHOR
teaching free open and gratis softwares. Don't hesitate to pay him for teaching free open and gratis softwares. Don't hesitate to pay him for
that services. that services.
$Id: imapsync,v 1.149 2006/02/14 00:44:44 gilles Exp gilles $ $Id: imapsync,v 1.152 2006/02/17 02:57:21 gilles Exp $

16
TODO
View file

@ -2,6 +2,10 @@ TODO file for imapsync
---------------------- ----------------------
Make --include --exclude options possibly be a list.
Create a imapsync mailing list. Create a imapsync mailing list.
Add features from Herman (patch against 1.139) Add features from Herman (patch against 1.139)
@ -31,9 +35,6 @@ Talk about :
(netscape or thunderbird is ok with dates) (netscape or thunderbird is ok with dates)
use the option --syncinternaldates " use the option --syncinternaldates "
Add usage about --regextrans2
To remove INBOX. in the name of destination folders :
--regextrans2 's/^INBOX\.(.+)/$1/'
Add cyrus link about INBOX. namespace Add cyrus link about INBOX. namespace
http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html
@ -45,6 +46,15 @@ Explain expunge behavior
Add a --recurse option when --folder option is used. Add a --recurse option when --folder option is used.
DONE. Add usage about --regextrans2
To remove INBOX. in the name of destination folders:
--regextrans2 's/^INBOX\.(.+)/$1/'
To sync a complete account in a subfolder called FOO:
--regextrans2 's/^INBOX(.*)/INBOX.FOO$1/'
DONE. Make the --justconnect a real "just connect" connection,
not a auth connection like it is now.
DONE. Add --prefix1 option. Don't know what is the need exactly. DONE. Add --prefix1 option. Don't know what is the need exactly.
The need is to remove this prefix when building target folder names. The need is to remove this prefix when building target folder names.

View file

@ -1 +1 @@
1.149 1.152

View file

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration. at IMAP migration.
$Revision: 1.149 $ $Revision: 1.152 $
=head1 INSTALL =head1 INSTALL
@ -45,7 +45,7 @@ $Revision: 1.149 $
[--regextrans2 <regex> --regextrans2 <regex> ...] [--regextrans2 <regex> --regextrans2 <regex> ...]
[--sep1 <char>] [--sep1 <char>]
[--sep2 <char>] [--sep2 <char>]
[--justfolders] [--justconnect] [--justfolders] [--justfoldersizes] [--justconnect]
[--syncinternaldates] [--syncinternaldates]
[--buffersize <int>] [--buffersize <int>]
[--syncacls] [--syncacls]
@ -192,9 +192,11 @@ Report any bugs to the author: lamiral@linux-france.org
=head1 IMAP SERVERS =head1 IMAP SERVERS
Failure story reported with the following imap server : Failure stories reported with the following imap servers :
- MailEnable 1.54 (Proprietary) http://www.mailenable.com/ - MailEnable 1.54 (Proprietary) http://www.mailenable.com/
- DBMail 2.0.7 (GPL). But DBMail 1.2.1 works.
Patient and confident testers are welcome.
Success stories reported with the following imap servers Success stories reported with the following imap servers
(softwares names are in alphabetic order) : (softwares names are in alphabetic order) :
@ -207,7 +209,7 @@ Success stories reported with the following imap servers
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.1.18 - Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.1.18
2.2.1, 2.2.2-BETA, 2.2.10, 2.2.12, 2.3-alpha (OSI Approved) 2.2.1, 2.2.2-BETA, 2.2.10, 2.2.12, 2.3-alpha (OSI Approved)
(http://asg.web.cmu.edu/cyrus/) (http://asg.web.cmu.edu/cyrus/)
- DBMail 1.2.1 (GPL) (http://www.dbmail.org/) - DBMail 1.2.1 (GPL) (http://www.dbmail.org/). 2.0.7 seems buggy.
- Dovecot 0.99.10.4 0.99.14 (LGPL) (http://www.dovecot.org/) - Dovecot 0.99.10.4 0.99.14 (LGPL) (http://www.dovecot.org/)
- Domino (Notes) 6.5, 5.0.6, 5.0.7 - Domino (Notes) 6.5, 5.0.6, 5.0.7
- Groupwise IMAP (Novell). Buggy so see the FAQ. - Groupwise IMAP (Novell). Buggy so see the FAQ.
@ -237,6 +239,9 @@ are useful to know the softwares. Example:
To software :* OK Courier-IMAP ready To software :* OK Courier-IMAP ready
You can use option --justconnect to get those lines. You can use option --justconnect to get those lines.
Example :
imapsync --host1 imap.troc.org --host2 imap.trac.org --justconnect
And please rate imapsync at http://freshmeat.net/projects/imapsync/ And please rate imapsync at http://freshmeat.net/projects/imapsync/
@ -308,7 +313,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services. softwares. Don't hesitate to pay him for that services.
$Id: imapsync,v 1.149 2006/02/14 00:44:44 gilles Exp gilles $ $Id: imapsync,v 1.152 2006/02/17 02:57:21 gilles Exp $
=cut =cut
@ -338,6 +343,7 @@ my(
$skipheader, @useheader, $skipheader, @useheader,
$skipsize, $foldersizes, $buffersize, $skipsize, $foldersizes, $buffersize,
$delete, $expunge, $expunge1, $expunge2, $dry, $delete, $expunge, $expunge1, $expunge2, $dry,
$justfoldersizes,
$authmd5, $authmd5,
$subscribed, $subscribe, $subscribed, $subscribe,
$version, $VERSION, $help, $version, $VERSION, $help,
@ -355,7 +361,7 @@ my(
use vars qw ($opt_G); # missing code for this will be option. use vars qw ($opt_G); # missing code for this will be option.
$rcs = ' $Id: imapsync,v 1.149 2006/02/14 00:44:44 gilles Exp gilles $ '; $rcs = ' $Id: imapsync,v 1.152 2006/02/17 02:57:21 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -392,8 +398,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.149 $ ', '$Revision: 1.152 $ ',
'$Date: 2006/02/14 00:44:44 $ ', '$Date: 2006/02/17 02:57:21 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient,"\n" $VERSION_IMAPClient,"\n"
@ -414,10 +420,37 @@ sub missing_option {
$host1 || missing_option("--host1") ; $host1 || missing_option("--host1") ;
$port1 = (defined($port1)) ? $port1 : 143; $port1 = (defined($port1)) ? $port1 : 143;
$user1 || missing_option("--user1");
$host2 || missing_option("--host2") ; $host2 || missing_option("--host2") ;
$port2 = (defined($port2)) ? $port2 : 143; $port2 = (defined($port2)) ? $port2 : 143;
sub connect_imap {
my($host, $port, $debugimap) = @_;
my $imap = Mail::IMAPClient->new();
$imap->Server($host);
$imap->Port($port);
$imap->Debug($debugimap);
$imap->connect()
or die "Can not open imap connection on [$host] : $@\n";
}
if ($justconnect) {
my $from = ();
my $to = ();
$from = connect_imap($host1, $port1);
print "From software : ", ($from->Report())[0];
print "From capability : ", join(" ", $from->capability()), "\n";
$to = connect_imap($host2, $port2);
print "To software : ", ($to->Report())[0];
print "To capability : ", join(" ", $to->capability()), "\n";
$from->logout();
$to->logout();
exit(0);
}
$user1 || missing_option("--user1");
$user2 || missing_option("--user2"); $user2 || missing_option("--user2");
$authmd5 = (defined($authmd5)) ? $authmd5 : 1; $authmd5 = (defined($authmd5)) ? $authmd5 : 1;
@ -532,6 +565,8 @@ sub md5auth() {
} }
print "From software : ", ($from->Report())[0]; print "From software : ", ($from->Report())[0];
print "To software : ", ($to->Report())[0]; print "To software : ", ($to->Report())[0];
@ -705,7 +740,7 @@ sub timenext {
return($timerel); return($timerel);
} }
exit if ($justconnect); exit if ($justfoldersizes);
# needed for setting flags # needed for setting flags
my $tohasuidplus = $to->has_capability("UIDPLUS"); my $tohasuidplus = $to->has_capability("UIDPLUS");
@ -1011,6 +1046,8 @@ FOLDER: foreach my $f_fold (@f_folders) {
print "Time : ", timenext(), " s\n"; print "Time : ", timenext(), " s\n";
} }
$from->logout();
$to->logout();
$timeend = time(); $timeend = time();
@ -1106,6 +1143,7 @@ sub get_options
"subscribe!" => \$subscribe, "subscribe!" => \$subscribe,
"justconnect!"=> \$justconnect, "justconnect!"=> \$justconnect,
"justfolders!"=> \$justfolders, "justfolders!"=> \$justfolders,
"justfoldersizes!" => \$justfoldersizes,
"fast!" => \$fast, "fast!" => \$fast,
"version" => \$version, "version" => \$version,
"help" => \$help, "help" => \$help,
@ -1230,6 +1268,9 @@ Several options are mandatory.
have NAMESPACE capability. have NAMESPACE capability.
--regextrans2 <regex> : Apply the whole regex to each destination folders. --regextrans2 <regex> : Apply the whole regex to each destination folders.
--regextrans2 <regex> : and this one. etc. --regextrans2 <regex> : and this one. etc.
When you play with the --regextrans2 option, first
add also the safe options --dry --justfolders
Then, when happy, remove --dry, remove --justfolders
--regexmess <regex> : Apply the whole regex to each message before transfer. --regexmess <regex> : Apply the whole regex to each message before transfer.
Exemple : 's/\\000/ /g' # to replace null by space. Exemple : 's/\\000/ /g' # to replace null by space.
--regexmess <regex> : and this one. --regexmess <regex> : and this one.
@ -1275,14 +1316,15 @@ Several options are mandatory.
on the "source" server. on the "source" server.
--(no)foldersizes : Calculate the size of each "From" folder in bytes --(no)foldersizes : Calculate the size of each "From" folder in bytes
and message counts. Meant to be used with and message counts. Meant to be used with
--justconnect. Turned on by default. --justfoldersizes. Turned on by default.
--justfoldersizes : exit after printed the folder sizes.
--syncacls : Synchronizes acls (Access Control Lists). --syncacls : Synchronizes acls (Access Control Lists).
--nosyncacls : Does not synchronize acls. This is the default. --nosyncacls : Does not synchronize acls. This is the default.
--debug : debug mode. --debug : debug mode.
--debugimap : imap debug mode. --debugimap : imap debug mode.
--version : print sotfware version. --version : print sotfware version.
--justconnect : just connect to both servers and print useful --justconnect : just connect to both servers and print useful
information. information. Need only --host1 and --host2 options.
--justfolders : just do things about folders (ignore messages). --justfolders : just do things about folders (ignore messages).
--fast : be faster (does not sync flags). --fast : be faster (does not sync flags).
--nofastio1 : don't use fastio with the "from" server. --nofastio1 : don't use fastio with the "from" server.
@ -1294,7 +1336,7 @@ Example: to synchronise imap account "foo" on "imap.truc.org"
to imap account "bar" on "imap.trac.org" to imap account "bar" on "imap.trac.org"
$0 \\ $0 \\
--host1 imap.troc.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

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# $Id: tests.sh,v 1.44 2005/11/28 01:27:44 gilles Exp $ # $Id: tests.sh,v 1.45 2006/02/17 02:51:12 gilles Exp gilles $
#### Shell pragmas #### Shell pragmas
@ -267,16 +267,31 @@ lp_justconnect()
if test X`hostname` = X"plume"; then if test X`hostname` = X"plume"; then
echo3 Here is plume echo3 Here is plume
./imapsync \ ./imapsync \
--host2 plume --user2 tata@est.belle \ --host2 plume \
--passfile2 /var/tmp/secret.tata \ --host1 loul \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect --justconnect
else else
: :
fi fi
} }
lp_justfoldersizes()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justfoldersizes
else
:
fi
}
lp_authmd5() lp_authmd5()
{ {
if test X`hostname` = X"plume"; then if test X`hostname` = X"plume"; then
@ -705,6 +720,7 @@ test $# -eq 0 && run_tests \
lp_subscribed \ lp_subscribed \
lp_subscribe \ lp_subscribe \
lp_justconnect \ lp_justconnect \
lp_justfoldersizes \
lp_authmd5 \ lp_authmd5 \
lp_maxage \ lp_maxage \
lp_maxsize \ lp_maxsize \