Solved: Re: [Dovecot] batch convert mbox to maildir

Netlink Tech tech at netlinkcom.com
Mon Apr 3 23:09:01 EEST 2006


I found this and it appears as though it will do exactly what I want:
http://people.redhat.com/rkeech/#dovecot

I am sure that writing the shell wrapper would also work, but someone else 
(Richard Keech and Philip Mak) already wrote the scripts to do this.

Thanks!

On Mon, 3 Apr 2006, Adam M. Dunn wrote:

>
> Since you only have a few hundred user's to convert, why just just write a
> quick shell wrapper on the command line.  Something like this (this is
> bourne or bash):
>
>
> # for user in `ls /var/spool/mail|egrep -v "root|daemon"`; do \
> echo md2md -s /var/spool/mail/$user -d /home/users/$user; \
> echo chown -R $user /home/users/$user/Maildir; \
> echo chown -R $user /home/users/$user/Maildir; \
> echo chmod -R 700 /home/users/$user/Maildir; done
>
>
> Logged in as 'root', that will loop through all files in /var/spool/mail
> (assuming the filenames are the same as the username) and convert them to
> Maildir in the userhome, then set the owner to themselves and make them
> 700 permissions.
>
> I haven't tested that, I just typed it out.  In fact I've never even used
> 'md2md', but the a 'for' wrapper is simple enough for anything.  So you
> may want to double check the md2md arguments.
>
> You can add user's you don't want to the 'egrep -v' list to ignore, OR,
> if you'd prefer, take the '-v' out and make it a list of user's to only
> do.  The 'echos' are there to just print what it will do for testing.
> Remove them when you have it like you want it.
>
>
> Hope that helps.
>
>
> ~Adam
>
>
>
> On Mon, 3 Apr 2006, Netlink Tech wrote:
>
>> Hello,
>> I have used mb2md for an individual user like this:
>>
>> su ~username
>> cd ~
>> ./mb2md -m
>>
>> This converted /var/spool/mail/username mbox to
>> /home/users/username/Maildir just as I expected.
>>
>> To convert 100s of users the same way would be a chore (su as each user
>> for permissions, etc.).
>>
>> Is there a way to batch process all /var/spool/mail/$USER to
>> /home/users/$USER/Maildir with the correct permissions/file owners for
>> each user?
>>
>>
>>
>
>


More information about the dovecot mailing list