This commit is contained in:
Nick Bebout 2011-03-12 02:44:25 +00:00
parent d34bdb8bd4
commit 25948aab90
7 changed files with 70 additions and 24 deletions

View file

@ -1,15 +1,20 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.167 head: 1.168
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 167; selected revisions: 167 total revisions: 168; selected revisions: 168
description: description:
---------------------------- ----------------------------
revision 1.168
date: 2006/04/02 01:49:10; author: gilles; state: Exp; lines: +32 -10
Added --delete2 option: remove messages on destination that
are not on the source server.
----------------------------
revision 1.167 revision 1.167
date: 2006/03/30 02:33:00; author: gilles; state: Exp; lines: +6 -6 date: 2006/03/30 02:33:00; author: gilles; state: Exp; lines: +6 -6
SPLIT print in debug mode only. SPLIT print in debug mode only.

10
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.167 $ $Revision: 1.168 $
INSTALL INSTALL
imapsync works fine under any Unix OS. imapsync works fine under any Unix OS.
@ -52,7 +52,8 @@ SYNOPSIS
[--skipheader <regex>] [--skipheader <regex>]
[--useheader <string>] [--useheader <string>] [--useheader <string>] [--useheader <string>]
[--skipsize] [--skipsize]
[--delete] [--expunge] [--expunge1] [--expunge2] [--delete] [--delete2]
[--expunge] [--expunge1] [--expunge2]
[--subscribed] [--subscribe] [--subscribed] [--subscribe]
[--nofoldersizes] [--nofoldersizes]
[--dry] [--dry]
@ -239,7 +240,8 @@ IMAP SERVERS
HUGE MIGRATION HUGE MIGRATION
Have a special attention on options --subscribed --subscribe --delete Have a special attention on options --subscribed --subscribe --delete
--expunge --expunge1 --expunge2 --maxage --minage --maxsize --useheader --delete2 --expunge --expunge1 --expunge2 --maxage --minage --maxsize
--useheader
If you have many mailboxes to migrate think about a little shell If you have many mailboxes to migrate think about a little shell
program. Write a file called file.csv (for example) containing users and program. Write a file called file.csv (for example) containing users and
@ -287,5 +289,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.167 2006/03/30 02:33:00 gilles Exp $ $Id: imapsync,v 1.168 2006/04/02 01:49:10 gilles Exp $

6
TODO
View file

@ -9,9 +9,6 @@ http://groups.google.fr/group/comp.mail.imap
Add my amazon wishlist link. Add my amazon wishlist link.
Add an --exactsync option to remove target messages
that are not on source. Maybe --delete2 is a better name.
Read the IMAP RFC http://www.faqs.org/rfcs/rfc3501.html Read the IMAP RFC http://www.faqs.org/rfcs/rfc3501.html
Add debian packaging in the Makefile. Add debian packaging in the Makefile.
@ -31,6 +28,9 @@ http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html
Explain expunge behavior. Explain expunge behavior.
DONE. Add an --exactsync option to remove target messages
that are not on source. Maybe --delete2 is a better name.
DONE. Fix the "word too large" or "Command line too long" DONE. Fix the "word too large" or "Command line too long"
bug with some imap servers. bug with some imap servers.

View file

@ -1 +1 @@
1.167 1.168

View file

@ -1,8 +1,10 @@
Project: imapsync Project: imapsync
Version: 1.166 Version: 1.167
Release-Focus: Major bugfixes Release-Focus: Minor feature enhancements
Hide: Y Hide: Y
Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Home-Page-URL: http://www.linux-france.org/prj/imapsync/
Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/ Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/
Code cleanup. Added --delete2 option: removes messages on destination that
are not on the source server.

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.167 $ $Revision: 1.168 $
=head1 INSTALL =head1 INSTALL
@ -58,7 +58,8 @@ $Revision: 1.167 $
[--skipheader <regex>] [--skipheader <regex>]
[--useheader <string>] [--useheader <string>] [--useheader <string>] [--useheader <string>]
[--skipsize] [--skipsize]
[--delete] [--expunge] [--expunge1] [--expunge2] [--delete] [--delete2]
[--expunge] [--expunge1] [--expunge2]
[--subscribed] [--subscribe] [--subscribed] [--subscribe]
[--nofoldersizes] [--nofoldersizes]
[--dry] [--dry]
@ -275,6 +276,7 @@ Have a special attention on options
--subscribed --subscribed
--subscribe --subscribe
--delete --delete
--delete2
--expunge --expunge
--expunge1 --expunge1
--expunge2 --expunge2
@ -337,7 +339,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.167 2006/03/30 02:33:00 gilles Exp $ $Id: imapsync,v 1.168 2006/04/02 01:49:10 gilles Exp $
=cut =cut
@ -369,7 +371,8 @@ my(
$maxsize, $maxage, $minage, $maxsize, $maxage, $minage,
$skipheader, @useheader, $skipheader, @useheader,
$skipsize, $foldersizes, $buffersize, $skipsize, $foldersizes, $buffersize,
$delete, $expunge, $expunge1, $expunge2, $dry, $delete, $delete2,
$expunge, $expunge1, $expunge2, $dry,
$justfoldersizes, $justfoldersizes,
$authmd5, $authmd5,
$subscribed, $subscribe, $subscribed, $subscribe,
@ -392,7 +395,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.167 2006/03/30 02:33:00 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.168 2006/04/02 01:49:10 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -429,8 +432,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.167 $ ', '$Revision: 1.168 $ ',
'$Date: 2006/03/30 02:33:00 $ ', '$Date: 2006/04/02 01:49:10 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient,"\n" $VERSION_IMAPClient,"\n"
@ -981,6 +984,21 @@ FOLDER: foreach my $f_fold (@f_folders) {
#print map { $f_hash{$_}{'m'} . " "} @f_hash_keys_sorted_by_uid; #print map { $f_hash{$_}{'m'} . " "} @f_hash_keys_sorted_by_uid;
my @t_hash_keys_sorted_by_uid
= sort {$t_hash{$a}{'m'} <=> $t_hash{$b}{'m'}} keys(%t_hash);
if($delete2) {
foreach my $m_id (@t_hash_keys_sorted_by_uid) {
#print "$m_id ";
unless (exists($f_hash{$m_id})) {
my $t_msg = $t_hash{$m_id}{'m'};
print "deleting message $m_id $t_msg\n";
$to->delete_message($t_msg) unless ($dry);
}
}
}
MESS: foreach my $m_id (@f_hash_keys_sorted_by_uid) { MESS: foreach my $m_id (@f_hash_keys_sorted_by_uid) {
my $f_size = $f_hash{$m_id}{'s'}; my $f_size = $f_hash{$m_id}{'s'};
my $f_msg = $f_hash{$m_id}{'m'}; my $f_msg = $f_hash{$m_id}{'m'};
@ -1196,6 +1214,7 @@ sub get_options
"regextrans2=s" => \@regextrans2, "regextrans2=s" => \@regextrans2,
"regexmess=s" => \@regexmess, "regexmess=s" => \@regexmess,
"delete!" => \$delete, "delete!" => \$delete,
"delete2!" => \$delete2,
"syncinternaldates!" => \$syncinternaldates, "syncinternaldates!" => \$syncinternaldates,
"syncacls!" => \$syncacls, "syncacls!" => \$syncacls,
"maxsize=i" => \$maxsize, "maxsize=i" => \$maxsize,
@ -1366,11 +1385,13 @@ Several options are mandatory.
--regexmess <regex> : and this one, etc. --regexmess <regex> : and this one, etc.
--sep1 <string> : separator in case namespace is not supported. --sep1 <string> : separator in case namespace is not supported.
--sep2 <string> : idem. --sep2 <string> : idem.
--delete : delete messages in source imap server after --delete : delete messages on source imap server after
a successful transfert. Useful in case you a successful transfert. Useful in case you
want to migrate from one server to another one. want to migrate from one server to another one.
With imap, delete tags messages as deleted, they With imap, delete tags messages as deleted, they
are not really deleted. See expunge. are not really deleted. See expunge.
--delete2 : delete messages on the destination imap server that
are not on the source server.
--expunge : expunge messages on source account. --expunge : expunge messages on source account.
expunge really deletes messages marked deleted. expunge really deletes messages marked deleted.
expunge is made at the begining on the expunge is made at the begining on the
@ -1417,8 +1438,9 @@ Several options are mandatory.
information. Need only --host1 and --host2 options. 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 (just does not sync flags). --fast : be faster (just does not sync flags).
--split1 : split the requests in several parts on source server. --split1 <int> : split the requests in several parts on source server.
--split2 : same thing on the "destination" server. <int > is the number of messages handled per request.
--split2 <int> : same thing on the "destination" server.
--nofastio1 : don't use fastio with the "from" server. --nofastio1 : don't use fastio with the "from" server.
--nofastio2 : don't use fastio with the "destination" server. --nofastio2 : don't use fastio with the "destination" server.
--timeout <int> : imap connect timeout. --timeout <int> : imap connect timeout.

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# $Id: tests.sh,v 1.51 2006/03/30 02:22:56 gilles Exp $ # $Id: tests.sh,v 1.52 2006/04/02 03:32:55 gilles Exp $
#### Shell pragmas #### Shell pragmas
@ -763,6 +763,21 @@ lp_authmech_CRAMMD5() {
fi fi
} }
lp_delete2() {
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 \
--folder INBOX \
--delete2 --expunge2
else
:
fi
}
# mandatory tests # mandatory tests