[Dovecot] batch convert mbox to maildir
Adam M. Dunn
adunn at hgsc.bcm.tmc.edu
Mon Apr 3 18:37:27 EEST 2006
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