#!/import/bw/tools/local/perl-5.8.0/bin/perl
use lib qw(/import/bw/tools/local/perl-5.8.0/lib/site_perl/5.8.0);
##---------------------------------------------------------------------------##
## $Id: mha-dbrecover,v 1.6 2001/11/18 07:25:34 ehood Exp $
## Earl Hood mhonarc@mhonarc.org
## Program to rebuild the MHonArc database file from message files.
##---------------------------------------------------------------------------##
## MHonArc -- Internet mail-to-HTML converter
## Copyright (C) 1998,2001 Earl Hood, mhonarc@mhonarc.org
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------##
unshift(@INC, 'lib'); # Should I leave this line in?
## Grab options from @ARGV unique to this program
Getopt::Long::Configure('pass_through');
my $startnum = $opts{'dbr-startnum'} || 0;
my $endnum = $opts{'dbr-endnum'} || -1;
## Reset pass-through of options
Getopt::Long::Configure('no_pass_through');
require 'mhamain.pl' || die qq/ERROR: Unable to require "mhamain.pl"\n/;
## Load library for reading message files
require 'mhmsgfile.pl' ||
die qq/ERROR: Unable to require "mhmsgfile.pl"\n/;
## Open archive: We use special -noarg option to tell mhonarc
## to not do any processing, just open archive and lock it.
unshift(@ARGV, '-noarg', '-lock');
if (!mhonarc::open_archive()) {
# unable to open, so abort processing
die "ERROR: Unable to open archive\n";
if (!opendir(DIR, $mhonarc::OUTDIR)) {
# unable to open archive directory
die qq/ERROR: Unable to open "$mhonarc::OUTDIR": $!\n"/;
print STDOUT "Rebuilding database in $mhonarc::OUTDIR ...\n"
## Define regular expressing for matching message files:
## we use message prefix and extension settings as defined
## by mhonarc. Make sure to capture message number from
# skip if not a message file
# skip if number less than start
# skip if number greater than end
next if ($endnum >= 0) && ($1 > $endnum);
# add file to list to process
# nothing found to process
die qq/ERROR: No message files found\n/;
## Read files. Use function in mhmsgfile.pl to extract data.
# get number for loading into mhonarc data structures
($num) = $_ =~ /$msgrex/o;
print STDOUT "." unless $mhonarc::QUIET;
$file = join($mhonarc::DIRSEP, $mhonarc::OUTDIR, $_);
# load date from message file into mhonarc
mhonarc::load_data_from_msg_file($file, $num);
## Define other data structures that need to be recovered.
$mhonarc::NumOfMsgs = scalar(@file);
@mhonarc::MListOrder = mhonarc::sort_messages();
mhonarc::compute_follow_ups(\@mhonarc::MListOrder);
mhonarc::compute_threads();
## Output recovered database file
print STDOUT "\nWriting database ...\n"
mhonarc::output_db($mhonarc::DBPathName);
if ($@) { warn $@; $ec = 1; }
mhonarc::close_archive();
##---------------------------------------------------------------------------##
mha-dbrecover - rebuild a MHonArc archive database
S<B<mha-dbrecover> [I<options>]>
B<mha-dbrecover> is a utility program that is part of the B<MHonArc>
software package. The program allows can be used to rebuild a
B<MHonArc> archive database from the HTML message files. This allows
database recovery if the database gets corrupted or accidentally
The documentation for B<MHonArc> is distributed in HTML format.
Due to its size and organization, it is not suited for manpage
format. Consult your system administrator for where the documentation
has been installed, or see L<"AVAILABILITY"> on where you can
access the documentation on the web.
B<mha-dbrecover> takes all the options available to B<mhonarc> along
with the following additional options:
=item C<-dbr-startnum> I<#>
The starting message number to recover data from. This option is
useful if you have many message files in a directory, but you only
want to recover a subset of the files.
If this option is not specified, the starting number is 0.
=item C<-dbr-endnum> I<#>
The ending message number to recover data from. This option is
useful if you have many message files in a directory, but you only
want to recover a subset of the files.
If this option is not specified, all messages starting from
C<-dbr-startnum> will be recovered.
B<NOTE:> Only a subset of the options available to B<mhonarc>
are actually supported since many options are not applicable for
E<lt>I<http://www.mhonarc.org/>E<gt>
Earl Hood, mhonarc@mhonarc.org