1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
This commit is contained in:
Nick Bebout 2011-03-12 02:44:16 +00:00
parent e0fc454e0d
commit 1ba81f554e
5 changed files with 59 additions and 38 deletions

View File

@ -1,15 +1,19 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.132 head: 1.133
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 132; selected revisions: 132 total revisions: 133; selected revisions: 133
description: description:
---------------------------- ----------------------------
revision 1.133
date: 2005/05/21 02:33:29; author: gilles; state: Exp; lines: +45 -31
Added foldersizes function
----------------------------
revision 1.132 revision 1.132
date: 2005/05/20 03:18:48; author: gilles; state: Exp; lines: +23 -16 date: 2005/05/20 03:18:48; author: gilles; state: Exp; lines: +23 -16
Updated doc with all options. Updated doc with all options.

8
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.132 $ $Revision: 1.133 $
INSTALL INSTALL
imapsync works fine under any Unix OS. imapsync works fine under any Unix OS.
@ -166,7 +166,7 @@ BUGS
IMAP SERVERS IMAP SERVERS
Success stories reported with the following imap servers (softwares Success stories reported with the following imap servers (softwares
inames are in alphabetic order) : names are in alphabetic order) :
- BincImap 1.2.3 - BincImap 1.2.3
- CommunicatePro server (Redhat 8.0) - CommunicatePro server (Redhat 8.0)
@ -207,7 +207,7 @@ 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 --maxage --maxsize --expunge --maxage --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
@ -253,5 +253,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.132 2005/05/20 03:18:48 gilles Exp $ $Id: imapsync,v 1.133 2005/05/21 02:33:29 gilles Exp $

3
TODO
View File

@ -2,6 +2,9 @@ TODO file for imapsync
---------------------- ----------------------
Add debian packaging in the Makefile.
Write to the debian maintener about that.
Interface with external software like procmail Interface with external software like procmail
Look at http://barnson.org/node/81 Look at http://barnson.org/node/81

View File

@ -1 +1 @@
1.132 1.133

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.132 $ $Revision: 1.133 $
=head1 INSTALL =head1 INSTALL
@ -191,7 +191,7 @@ Report any bugs to the author: lamiral@linux-france.org
=head1 IMAP SERVERS =head1 IMAP SERVERS
Success stories reported with the following imap servers Success stories reported with the following imap servers
(softwares inames are in alphabetic order) : (softwares names are in alphabetic order) :
- BincImap 1.2.3 - BincImap 1.2.3
- CommunicatePro server (Redhat 8.0) - CommunicatePro server (Redhat 8.0)
@ -241,6 +241,7 @@ Have a special attention on options
--expunge --expunge
--maxage --maxage
--maxsize --maxsize
--useheader
If you have many mailboxes to migrate think about a little If you have many mailboxes to migrate think about a little
shell program. Write a file called file.csv (for example) shell program. Write a file called file.csv (for example)
@ -295,7 +296,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.132 2005/05/20 03:18:48 gilles Exp $ $Id: imapsync,v 1.133 2005/05/21 02:33:29 gilles Exp $
=cut =cut
@ -340,7 +341,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.132 2005/05/20 03:18:48 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.133 2005/05/21 02:33:29 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -377,8 +378,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.132 $ ', '$Revision: 1.133 $ ',
'$Date: 2005/05/20 03:18:48 $ ', '$Date: 2005/05/21 02:33:29 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient, " auth md5 : $md5_supported", $VERSION_IMAPClient, " auth md5 : $md5_supported",
@ -447,25 +448,28 @@ unless ($md5_supported) {
$timestart = time(); $timestart = time();
$timebefore = $timestart; $timebefore = $timestart;
my $fastio1 = 1;
my $fastio2 = 1;
$debugimap and print "From connection\n"; $debugimap and print "From connection\n";
$from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout); $from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout, $fastio1);
$debugimap and print "To connection\n"; $debugimap and print "To connection\n";
$to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout); $to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout, $fastio2);
# No history # No history
$from->Clear(1); $from->Clear(2);
$to->Clear(1); $to->Clear(2);
sub login_imap { sub login_imap {
my($host, $port, $user, $password, my($host, $port, $user, $password,
$debugimap, $timeout, $authmech) = @_; $debugimap, $timeout, $fastio) = @_;
my $imap = Mail::IMAPClient->new(); my $imap = Mail::IMAPClient->new();
$imap->Server($host); $imap->Server($host);
$imap->Port($port); $imap->Port($port);
$imap->Fast_io(1); $imap->Fast_io($fastio);
$imap->Buffer($buffersize || 65536); $imap->Buffer($buffersize || 4096);
$imap->Uid(1); $imap->Uid(1);
$imap->Peek(1); $imap->Peek(1);
$imap->Debug($debugimap); $imap->Debug($debugimap);
@ -588,36 +592,40 @@ sub get_separator {
print "From separator : [$f_sep]\n"; print "From separator : [$f_sep]\n";
print "To separator : [$t_sep]\n"; print "To separator : [$t_sep]\n";
if ($foldersizes) {
sub foldersizes {
my ($side, $imap, $folders_r) = @_;
my $tot = 0; my $tot = 0;
my $tmess = 0; my $tmess = 0;
my @folders = @{$folders_r};
print "++++ Calculating sizes ++++\n"; print "++++ Calculating sizes ++++\n";
foreach my $f_fold (@f_folders) { foreach my $folder (@folders) {
my $stot = 0; my $stot = 0;
my $smess = 0; my $smess = 0;
printf("From Folder %-35s", "[$f_fold]"); printf("$side Folder %-35s", "[$folder]");
unless ($from->select($f_fold)) { unless ($imap->select($folder)) {
warn warn
"From Folder $f_fold : Could not select ", "$side Folder $folder : Could not select ",
$from->LastError, "\n"; $imap->LastError, "\n";
$error++; $error++;
next; next;
} }
if ($maxage) { if ($maxage) {
# The pb is fetch_hash() can only be applied on ALL messages # The pb is fetch_hash() can only be applied on ALL messages
my @f_msgs = $from->since(time - 86400 * $maxage); my @msgs = $imap->since(time - 86400 * $maxage);
my $smess = scalar(@f_msgs); my $smess = scalar(@msgs);
foreach my $m (@f_msgs) { foreach my $m (@msgs) {
my $s = $from->size($m) my $s = $imap->size($m)
or warn "Could not find size of message $m: $@\n"; or warn "Could not find size of message $m: $@\n";
$stot += $s; $stot += $s;
} }
}else{ }else{
my $hashref = {}; my $hashref = {};
$smess = $from->message_count(); $smess = $imap->message_count();
unless ($smess == 0) { unless ($smess == 0) {
$from->fetch_hash("RFC822.SIZE",$hashref); $imap->fetch_hash("RFC822.SIZE",$hashref);
#print map {$hashref->{$_}->{"RFC822.SIZE"}, " "} keys %$hashref; #print map {$hashref->{$_}->{"RFC822.SIZE"}, " "} keys %$hashref;
map {$stot += $hashref->{$_}->{"RFC822.SIZE"}} keys %$hashref; map {$stot += $hashref->{$_}->{"RFC822.SIZE"}} keys %$hashref;
} }
@ -630,9 +638,15 @@ if ($foldersizes) {
print "Total size: $tot\n"; print "Total size: $tot\n";
print "Total messages: $tmess\n"; print "Total messages: $tmess\n";
print "Time : ", timenext(), " s\n"; print "Time : ", timenext(), " s\n";
} }
if ($foldersizes) {
foldersizes("From", $from, \@f_folders);
foldersizes("To ", $to, \@t_folders);
}
sub timenext { sub timenext {
my ($timenow, $timerel); my ($timenow, $timerel);
# $timebefore is global, beurk ! # $timebefore is global, beurk !