A script some folks might find useful

Rob Tanner rtanner at linfield.edu
Tue Nov 2 12:39:33 EST 2004


When I upgraded to Cyrus IMAP v2.2.3 from an age old ESYS version (a
commercial knock off of a v.1.x).  I used imapsync to move the mail spools
from one server to another and then after all was up and going a crash caused
the mailboxes database to be irreparably damaged.  Yikes, the "-m"
functionality is diabled in the reconstruct utility.

I wrote the following perl script to mine the information necessary to
rebuild the mailboxes database and write it to a file, and so I thought I'd
pass it on.  I only use a single default partition (some 280GB fully
mirrored).  If someone has multiple partitions, it would not be that big a
task to have the program read /etc/imapd.conf and do each partition
separately.


#! /usr/bin/perl

use strict;

my $SPOOL = '/var/spool/imap';

foreach my $ltr ( 'A' .. 'Z' ) {
  chdir "${SPOOL}/${ltr}/user";

  my @dirs = `find . -type d`;

  foreach my $dir ( @dirs )
	{
	  chomp $dir;

	  # Things to ignore
	  next if $dir eq ".";
	  next unless -f "${dir}/cyrus.header";

	  # ACLs are the last line in the cyrus.header file
	  my @cyrus_header = `cat \"${dir}/cyrus.header\"`;
	  my $acl = pop @cyrus_header;
	  chomp $acl;

	  #
	  # Replace the leading "./" returned
	  # by the find command with "user."
	  #

	  $dir =~ s/^\.\//user./;

	  #
	  # Replace directory path slashes
	  # ("/") with dots (".")
	  #

	  $dir =~ s/\//./g;

	  # Write result to STDOUT
	  print $dir, "\tdefault\t",  $acl, "\n";
	}
}


-- 
Rob Tanner
UNIX Services Manager
Linfield College, McMinnville OR

---
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




More information about the Info-cyrus mailing list