Easiest way is

as the cyrus user run,
sync_client -r

We have an init.d script to start sync_client back up, and another perl script that connects to cyrus and makes a sync log file of all the accounts on the machine. We then feed the log file to sync_client to process.
Lastly, we have a sanity check script that compares user quota usage  
on the primary machine and the replica. This way we can easily spot  
any discrepancies and fix them.

I've attached the scripts in case anyone wants them as a starting pont (they contain some columbia specific stuff) and probably need some editing to work on your system.



Attachment: sync_client
Description: Binary data


List mailboxes is loosely based on the imapcreate.pl script
#!/usr/bin/perl -w
#
#This will output a file containing all mailboxes in a format for sync_client
#Each shared mailbox will be outputed as
#MAILBOX mailboxname
#Each user account will be outputed as
#USER username
#
#

# 
use Getopt::Long;
use Cyrus::IMAP::Admin;
use strict;

# CLI options
my ($debug,$authmech,$pass,$cyrus);

#Conncetion variables
my ($user);
sub usage {
    print "listmailboxes - formats mailbox list in a way that sync_client understands";
  print "  usage:\n";
  print "	listmailboxes   [--auth mechanism] [-p pass] <server>\n";
  print "\n";
  print "If no password is submitted with -p, we'll prompt for one.\n";
  print "if -v is set, we'll run in debug mode, and print information on stdout\n";
  print "\n";
  print "The default mechanism is used for authentication. If you need another\nmechanism, (try LOGIN), use --auth <mechanism> option\n";
  print "\n";
    print " example: Must run as the CYRUS user\n";
    print "       listmailboxes.pl --auth GSSAPI localhost";
  print "\n";
  exit 0;
}


GetOptions( "auth=s" => \$authmech, 
	    "p|pass=s" => \$pass, 
	    "v|verbose" => \$debug );


my $server = shift(@ARGV) if (@ARGV);
usage unless $server;
$user="cyrus";

# Authenticate
print "Connecting\n";
$cyrus = Cyrus::IMAP::Admin->new($server);

if ($authmech) {
	$cyrus->authenticate(-mechanism => $authmech, 
			-user => $user,
	 		-password => $pass);
}
 else {
$cyrus->authenticate(
		     -user => $user,
		     -password => $pass);
}
die $cyrus->error if $cyrus->error;


unless (open SYNCFILE, "> /var/cyrus/sync/listing.log") {
    die "Cannot create syncfile: $!";
}


print "Writing mailbox list to /var/cyrus/sync/listing.log\n";
my @mailboxesT = $cyrus->list('%', 'user.');
foreach my $mailbox (@mailboxesT) {

    $mailbox->[0] =~ s/user\.(.*)/user $1/;
    print SYNCFILE "$mailbox->[0]\n";

}
my @sharedT = $cyrus->list('%', '');
foreach my $sharedbox (@sharedT) {

    if($sharedbox->[0] ne 'user') {
	print SYNCFILE "MAILBOX $sharedbox->[0]\n";
	my @subsharedT = $cyrus->list('*',"$sharedbox->[0].");
	foreach my $subsharedbox (@subsharedT) {
	    print SYNCFILE "MAILBOX $subsharedbox->[0]\n";
	}
    }
#    $mailbox->[0] =~ s/user\.(.*)/user $1/;
#    print SYNCFILE "$mailbox->[0]\n";

}
close SYNCFILE;



Cyrus_sync_check ssh's into our primary machines and into the replicas and calls 'cyr_quota'. It then diffs the output of the primary and the replica and pipes it to awk to make the output pretty.
It uses a columbia specific tool called 'ourhosts', and relies on the  
fact that our replica machines have the same name as the primaries  
but with a 2 stuck on the end.

Attachment: cyrus_sync_check
Description: Binary data



-Patrick

On Dec 20, 2005, at 10:03 AM, Patrice wrote:

ok, I understand better now,  thank you !

what would be the best way to restart it ?
stop/start cyrus   or  another command ?

thanks

Patrice


Patrick H Radtke wrote:


If sync_client cannot contact the replica server (or if there is some other error that it can't recover from) then it 'bails out' and stops running.
I guess the idea being that sync_client can't do aynthing until  
you fix the problem.
We run monitoring software that lets us know if sync_client dies,  
and attempts to restart it for us.

-Patrick






On Tue, 20 Dec 2005, Patrice wrote:


Hi,

yesterday evening my replication was working on my test system.
I unplugged network and came back today , plugged it again.

I tried to send an email but this one wasn't replicated on the replica. (I waited a few minutes and my sync_repeat_interval is 60)
I made a "ps aux" and saw that the 2 processes sync_client where  
not existing
that was the cause of no replication.

my authentication is made via saslauthd on another server on openldap

if authentication cannot be made, it seems that sync_client  die

I launched by hand:
su - cyrus -c "/cyrus-imap/bin/sync_client -r"
--> sync ok
and now  2 processes sync_client now are running.

here is my config for replication:

sync_host: 192.168.1.2
sync_authname: cyrus
sync_password: xxxxxxxxxx
sync_machineid: 1
sync_log: yes
sync_repeat_interval: 60



and ideas about this behavior ?

thanks in advance

Patrice




----
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html








----
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

Reply via email to