
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Mail archiving question
On 04/08/07, Jim Breen <jimbreen@example.com> wrote:
> On 04/08/07, Stephen J. Turnbull <stephen@example.com> wrote:
>
> > MHonArc may have an appropriate option.
>
> Thanks. I'll look into that. We actually have the archive system
> already, with regex searching, etc. It's the one-off importing of
> a batch of emails that's needed.
It does. Here is how I used it plus formail to do a similar thing:
# Become the mailing list user
sudo su - list
# Don't mess with this stuff unless you really know what you are doing
ARCHIVE_ROOT='./archive'
MBOX_ROOT='/var/spool/mail/list'
# Change this to the list you want to rebuild
LIST_NAME='testing'
# Back up the current archives
for i in \
`find "${ARCHIVE_ROOT}${LIST_NAME}/" -type d | grep -v .svn | sed -e 1d`; do
mv "${i}" "${i}.BAK"
done
# Rebuild from Mailman's private archives
cat "${MBOX_ROOT}${LIST_NAME}.mbox/${LIST_NAME}.mbox" \
| formail -s \
perl -e 'while (<>) {
# For the first line, parse the From chunk
exit 1 unless $. > 1 or
/^From\s
\S+\s # email address
(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s
\d{2}\s # month
\d{2}:\d{2}:\d{2}\s # time
\d{2}(\d{2})$ # year
/x;
my $mon =
{
Jan => "01",
Feb => "02",
Mar => "03",
Apr => "04",
May => "05",
Jun => "06",
Jul => "07",
Aug => "08",
Sep => "09",
Oct => "10",
Nov => "11",
Dec => "12",
}->{$2}
or exit 2;
my $year = $3 or exit 3;
# If this is line 1, open the pipe
if ($. == 1) {
open ARCHIVER,
"| "/usr/bin/mhonarc -quiet -spammode -outdir
${LIST_NAME}/$year$mon -rcfile ${LIST_NAME}/main.rc -umask 002 -add"
or die "Cannot run mhonarc: $!";
warn $_;
}
print ARCHIVER $_;
}
close ARCHIVER;
'
Is that close enough to what you need to do to be of any use?
--
Cheers,
Josh
Home |
Main Index |
Thread Index