Re: [Exim] Hi. moving to maildir. looking for suggestions

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Greg Ward
日付:  
To: exim-users
題目: Re: [Exim] Hi. moving to maildir. looking for suggestions
--
On 22 January 2002, Derrick said:
> what would you people suggest as a way to move the files from one server
> to another? Should I tar the /var/mail contents, then ftp, then find a
> script to convert the format and drop them into the
> /home/username/Maildir?


Personally, I would use scp for the transfer, but that's a side issue.
(What? You mean there are *still* people using ftp for this sort of
thing?)

Also, I can share a bit of knowledge I learned the hard way today: if
you use one of the mbox-to-maildir Perl scripts, floating around the
net, *you will lose*. I found two of these with Google today, and
they're both based on five-year-old code, and they both fail silently on
messages that look like this:

Blah blah blah.

Blah blah
From blah blah blah
blah blah.

That is, both of these tools (called mbox2maildir and mb2md) treat
"\nFrom " as the delimiter between messages, when the correct delimiter
is "\n\nFrom ". Sigh.

Luckily, I found a working solution at
http://www.nb.net/~lbudney/linux/software/safecat/one-liners.html

I'll attach my shell script; note that it requires formail (included
with procmail) and safecat
(http://www.nb.net/~lbudney/linux/software/safecat.html).

        Greg
--
Greg Ward - software developer                gward@???
MEMS Exchange                            http://www.mems-exchange.org
--
#!/bin/sh


# Convert an mbox mail file to a maildir.
# Requires formail and safecat.
# Idea stolen from
# http://www.nb.net/~lbudney/linux/software/safecat/one-liners.html
#
# by Greg Ward, 2002/01/22
#
# Usage:
# mb2md mbox maildir
# where mbox must exist, and maildir must not exist.

if [ "$#" -ne 2 ] ; then
echo "usage: $0 mbox maildir" >&2
exit 1
fi

mbox=$1
maildir=$2

if [ -e "$maildir" ] ; then
echo "$maildir already exists" >&2
exit 1
fi

if [ ! -e "$mbox" ] ; then
echo "$mbox does not exist" >&2
exit 1
fi

mkdir -p $maildir/{cur,new,tmp}
formail -I"From " -s safecat $maildir/tmp $maildir/new < $mbox
--