This commit is contained in:
Nick Bebout 2011-03-12 02:43:48 +00:00
parent a50a15a2c1
commit 33536c36b4
5 changed files with 88 additions and 29 deletions

View file

@ -1,15 +1,24 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.40 head: 1.42
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 40; selected revisions: 40 total revisions: 42; selected revisions: 42
description: description:
---------------------------- ----------------------------
revision 1.42
date: 2003/10/20 22:56:57; author: gilles; state: Exp; lines: +27 -16
Added --syncinternaldates option
----------------------------
revision 1.41
date: 2003/10/20 19:19:52; author: gilles; state: Exp; lines: +9 -4
RFC 2060: \Recent can not be altered by the client.
Thanks to Tomasz Orzechowski <tomek AT lj.pl>
----------------------------
revision 1.40 revision 1.40
date: 2003/10/17 01:34:59; author: gilles; state: Exp; lines: +5 -5 date: 2003/10/17 01:34:59; author: gilles; state: Exp; lines: +5 -5
Added condition to add prefix2 Added condition to add prefix2

13
README
View file

@ -1,7 +1,7 @@
NAME NAME
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.40 $ $Revision: 1.42 $
INSTALL INSTALL
Get imapsync at http://www.linux-france.org/prj/imapsync/dist/ Get imapsync at http://www.linux-france.org/prj/imapsync/dist/
@ -21,6 +21,7 @@ SYNOPSIS
[--user2 <string>] [--passfile2 <string>] [--user2 <string>] [--passfile2 <string>]
[--folder <string> --folder <string> ...] [--folder <string> --folder <string> ...]
[--prefix2 <string>] [--prefix2 <string>]
[--syncinternaldate]
[--delete] [--expunge] [--delete] [--expunge]
[--dry] [--dry]
[--debug] [--debugimap] [--debug] [--debugimap]
@ -112,10 +113,16 @@ IMAP SERVERS
- CommunicatePro server (Redhat 8.0) - CommunicatePro server (Redhat 8.0)
- SunONE Messaging server 5.2 - SunONE Messaging server 5.2
- iPlanet Messaging server 4.15 - iPlanet Messaging server 4.15
- dovecot ?.??
Please report to the author any success or bad story with imapsync and Please report to the author any success or bad story with imapsync and
don't forget to mention the IMAP server software names and version on don't forget to mention the IMAP server software names and version on
both sides. This will help future users. both sides. This will help future users. To help the author maintaining
this section report the two lines at the begining of the output if they
are useful to know the softwares. Example:
From software :* OK louloutte Cyrus IMAP4 v1.5.19 server ready
To software :* OK Courier-IMAP ready
Rate imapsync : http://freshmeat.net/projects/imapsync/ Rate imapsync : http://freshmeat.net/projects/imapsync/
@ -127,5 +134,5 @@ SIMILAR SOFTWARES
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.40 2003/10/17 01:34:59 gilles Exp $ $Id: imapsync,v 1.42 2003/10/20 22:56:57 gilles Exp $

View file

@ -1 +1 @@
1.40 1.42

View file

@ -4,7 +4,7 @@
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.40 $ $Revision: 1.42 $
=head1 INSTALL =head1 INSTALL
@ -26,6 +26,7 @@ $Revision: 1.40 $
[--user2 <string>] [--passfile2 <string>] [--user2 <string>] [--passfile2 <string>]
[--folder <string> --folder <string> ...] [--folder <string> --folder <string> ...]
[--prefix2 <string>] [--prefix2 <string>]
[--syncinternaldate]
[--delete] [--expunge] [--delete] [--expunge]
[--dry] [--dry]
[--debug] [--debugimap] [--debug] [--debugimap]
@ -131,10 +132,17 @@ Success stories reported :
- CommunicatePro server (Redhat 8.0) - CommunicatePro server (Redhat 8.0)
- SunONE Messaging server 5.2 - SunONE Messaging server 5.2
- iPlanet Messaging server 4.15 - iPlanet Messaging server 4.15
- dovecot ?.??
Please report to the author any success or bad story with imapsync and Please report to the author any success or bad story with
don't forget to mention the IMAP server software names and version on imapsync and don't forget to mention the IMAP server
both sides. This will help future users. software names and version on both sides. This will help
future users. To help the author maintaining this section
report the two lines at the begining of the output if they
are useful to know the softwares. Example:
From software :* OK louloutte Cyrus IMAP4 v1.5.19 server ready
To software :* OK Courier-IMAP ready
Rate imapsync : http://freshmeat.net/projects/imapsync/ Rate imapsync : http://freshmeat.net/projects/imapsync/
@ -147,7 +155,7 @@ Rate imapsync : http://freshmeat.net/projects/imapsync/
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.40 2003/10/17 01:34:59 gilles Exp $ $Id: imapsync,v 1.42 2003/10/20 22:56:57 gilles Exp $
=cut =cut
@ -162,7 +170,8 @@ my(
$rcs, $debug, $debugimap, $error, $rcs, $debug, $debugimap, $error,
$host1, $host2, $port1, $port2, $host1, $host2, $port1, $port2,
$user1, $user2, $password1, $password2, $passfile1, $passfile2, $user1, $user2, $password1, $password2, $passfile1, $passfile2,
@folder, $prefix2, @folder, $prefix2,
$syncinternaldates,
$delete, $expunge, $dry, $delete, $expunge, $dry,
$version, $VERSION, $help, $version, $VERSION, $help,
); );
@ -170,12 +179,12 @@ 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.40 2003/10/17 01:34:59 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.42 2003/10/20 22:56:57 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
$error=0; $error=0;
my $banner = '$RCSfile: imapsync,v $ ' . '$Revision: 1.40 $ ' . '$Date: 2003/10/17 01:34:59 $ ' . "\n"; my $banner = '$RCSfile: imapsync,v $ ' . '$Revision: 1.42 $ ' . '$Date: 2003/10/20 22:56:57 $ ' . "\n";
get_options(); get_options();
@ -330,14 +339,17 @@ FOLDER: foreach my $f_fold (@f_folders) {
print "Copying msg #$f_msg:$f_size to folder $t_fold\n"; print "Copying msg #$f_msg:$f_size to folder $t_fold\n";
unless ($dry) { unless ($dry) {
my $string = $from->message_string($f_msg); my $string = $from->message_string($f_msg);
#my $d = $from->internaldate($f_msg); my $d = $from->internaldate($f_msg);
#my $date_f = `date -d"$d" "+%d-%b-%Y %T %z"`; $d = "\"$d\"";
#print "date from 1: [$d]\n"; $debug and print "internal date from 1: [$d]\n";
#print "date from 2: [$date_f]\n"; $syncinternaldates or $d = "";
my $flags_f = join(" ", @{$from->flags($f_msg)}); my $flags_f = join(" ", @{$from->flags($f_msg)});
# RFC 2060 : This flag can not be altered by the client
$flags_f =~ s@\\Recent@@g;
my $new_id; my $new_id;
print "flags from : [$flags_f]\n"; print "flags from : [$flags_f][$d]\n";
unless($new_id = $to->append_string($t_fold,$string, $flags_f)){ unless($new_id = $to->append_string($t_fold,$string, $flags_f, $d)){
warn "Couldn't append msg #$f_msg to folder $t_fold", warn "Couldn't append msg #$f_msg to folder $t_fold",
$to->LastError, "\n"; $to->LastError, "\n";
$error++; $error++;
@ -361,6 +373,8 @@ FOLDER: foreach my $f_fold (@f_folders) {
$debug and print "Setting flags\n"; $debug and print "Setting flags\n";
my (@flags_f,@flags_t); my (@flags_f,@flags_t);
@flags_f = @{$from->flags($f_msg)}; @flags_f = @{$from->flags($f_msg)};
# No flag \Recent here, no ?
$to->store($t_msg, $to->store($t_msg,
"+FLAGS (" . join(" ", @flags_f) . ")" "+FLAGS (" . join(" ", @flags_f) . ")"
); );
@ -414,8 +428,8 @@ sub get_options
{ {
my $numopt = scalar(@ARGV); my $numopt = scalar(@ARGV);
my $opt_ret = GetOptions( my $opt_ret = GetOptions(
"debug" => \$debug, "debug!" => \$debug,
"debugimap" => \$debugimap, "debugimap!" => \$debugimap,
"host1=s" => \$host1, "host1=s" => \$host1,
"host2=s" => \$host2, "host2=s" => \$host2,
"port1=i" => \$port1, "port1=i" => \$port1,
@ -429,6 +443,7 @@ sub get_options
"folder=s" => \@folder, "folder=s" => \@folder,
"prefix2=s" => \$prefix2, "prefix2=s" => \$prefix2,
"delete!" => \$delete, "delete!" => \$delete,
"syncinternaldates!" => \$syncinternaldates,
"dry!" => \$dry, "dry!" => \$dry,
"expunge!" => \$expunge, "expunge!" => \$expunge,
"version" => \$version, "version" => \$version,
@ -511,6 +526,7 @@ Several options are mandatory.
are not really deleted. See expunge. are not really deleted. See expunge.
--expunge : expunge messages on both account. --expunge : expunge messages on both account.
expunge delete messages marked deleted. expunge delete messages marked deleted.
--syncinternaldates : set the internal dates on host2 same as host1
--dry : do nothing, just print what would be done. --dry : do nothing, just print what would be done.
--debug : debug mode. --debug : debug mode.
--debugimap : imap debug mode. --debugimap : imap debug mode.

View file

@ -1,8 +1,14 @@
#!/bin/sh #!/bin/sh
# $Id: tests.sh,v 1.7 2003/10/17 01:34:16 gilles Exp $ # $Id: tests.sh,v 1.9 2003/10/20 22:53:29 gilles Exp $
# $Log: tests.sh,v $ # $Log: tests.sh,v $
# Revision 1.9 2003/10/20 22:53:29 gilles
# Added lp_internaldate()
#
# Revision 1.8 2003/10/20 21:49:47 gilles
# wrote sendtestmessage()
#
# Revision 1.7 2003/10/17 01:34:16 gilles # Revision 1.7 2003/10/17 01:34:16 gilles
# Added lp_folder_qqq() test # Added lp_folder_qqq() test
# #
@ -82,14 +88,18 @@ first_sync() {
--passfile2 /var/tmp/secret2 --passfile2 /var/tmp/secret2
} }
sendtestmessage() {
rand=`pwgen 16 1`
mess='test:'$rand
cmd="echo $mess""| mail -s ""$mess"" tata"
echo $cmd
ssh gilles@loul $cmd
}
loulplume() { loulplume() {
if test X`hostname` = X"plume"; then if test X`hostname` = X"plume"; then
echo3 Here is plume echo3 Here is plume
rand=`pwgen 16 1` sendtestmessage
mess='test:'$rand
cmd="echo $mess""| mail -s ""$mess"" tata"
echo $cmd
ssh gilles@loul $cmd
#sleep 10 #sleep 10
./imapsync \ ./imapsync \
--host1 loul --user1 tata \ --host1 loul --user1 tata \
@ -143,6 +153,22 @@ lp_folder_qqq() {
fi fi
} }
lp_internaldate() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
sendtestmessage
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--folder INBOX \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--syncinternaldates
else
:
fi
}
@ -177,7 +203,8 @@ test $# -eq 0 && run_tests \
plumeloul \ plumeloul \
lp_folder \ lp_folder \
pl_folder \ pl_folder \
lp_folder_qqq lp_folder_qqq \
lp_internaldate
# selective tests # selective tests