mboxからMaildirに移行した作業メモです。今回はmb2md-3.20.plを使用しました。
Converting Mbox mailboxes to Maildir format:
http://batleth.sapienti-sat.org/projects/mb2md/
【移行元】
・sendmail Version 8.12.11.20060308
・Qpopper version 4.0.9 (non-standalone)
・mbox
【移行先】
・postfix 2.6.6
・dovecot 2.0.9
・Maildir
下記のサイトに多くの情報がありDovecot用に改変したmb2md.plもありますが、これで検証したところ未読、既読の情報となる”Status: RO“がコンバート時に削除されてしまい、クライアント側ですべてのメールを再受信してしまいました。
※サーバにメールを残す設定にしていなければすべて未読メールなので大丈夫と思います。
Converting between mailbox formats
http://wiki2.dovecot.org/Migration/MailFormat
- mb2md-3.20.plでコンバート実行
- Dovecotの設定変更
1 2 3 4 5 6 |
$ perl mb2md-3.20.pl -h Usage: mb2md -h mb2md [-c] -m [-d destdir] mb2md [-c] -s sourcefile [-d destdir] mb2md [-c] -s sourcedir [-l wu-mailboxlist] [-R|-f somefolder] [-d destdir] [-r strip_extension] |
1 2 3 4 5 |
$ perl mb2md-3.20.pl -s mbox -d Maildir Converting /home/matsuoka/mbox to maildir: /home/matsuoka/Maildir Source Mbox is /home/matsuoka/mbox Target Maildir is /home/matsuoka/Maildir 2 messages. |
下記のサイトにあるように”pop3_reuse_xuidl=yes“に変更します。
Migration to Dovecot
http://wiki2.dovecot.org/Migration
1 2 3 4 5 6 7 |
# vi /etc/dovecot/conf.d/20-pop3.conf # grep pop3_reuse_xuidl /etc/dovecot/conf.d/20-pop3.conf #pop3_reuse_xuidl = no pop3_reuse_xuidl = yes # /etc/init.d/dovecot restart Stopping Dovecot Imap: [ OK ] Starting Dovecot Imap: [ OK ] |
クライアント outlook 2016ですべてのメールを再受信しないで、新規メールから受信してくれたので大丈夫かな。
勉強のついでなのでmb2md.plの使用法も記載しておきます。
mb2md.pl
1 2 3 4 5 6 |
$ perl mb2md.pl -h Usage: mb2md -h mb2md [-c] [-K] [-U|-u] [-S] [-W] -m [-d destdir] mb2md [-c] [-K] [-U|-u] [-S] [-W] -s sourcefile [-d destdir] mb2md [-c] [-K] [-U|-u] [-S] [-W] -s sourcedir [-l wu-mailboxlist] [-R|-f somefolder] [-d destdir] [-r strip_extension] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
#!/usr/bin/perl -w # # $Id: mb2md.pl,v 1.26 2004/03/28 00:09:46 juri Exp $ # mb2md-3.20.pl Converts Mbox mailboxes to Maildir format. # # !! This is a version modified for Dovecot. Use Dovecot mailing list # !! <dovecot@dovecot.org> for questions, patches, etc. You don't have to be # !! subscribed to send mail there. Do not send mail directly to people # !! listed below. # USAGE # ===== # # Run this as the user of the mailboxes, not as root. # # # mb2md -h # mb2md [-c] [-K] [-U|-u] [-S] [-W] -m [-d destdir] # mb2md [-c] [-K] [-U|-u] [-S] [-W] -s sourcefile [-d destdir] # mb2md [-c] [-K] [-U|-u] [-S] [-W] -s sourcedir [-l wu-mailboxlist] [-R|-f somefolder] [-d destdir] [-r strip_extension] # # -c use the Content-Length: headers (if present) to find the # beginning of the next message # Use with caution! Results may be unreliable. I recommend to do # a run without "-c" first and only use it if you are certain, # that the mbox in question really needs the "-c" option # # -K Preserve message keywords in a Dovecot-compatible way. This # looks for X-Keywords: tags and X-IMAP: and X-IMAPbase: tags # to determine keywords for messages and creates a Dovecot- # compatible "dovecot-keywords" file in "destdir" # NOTE: NO LOCKING IS DONE AND THE FILE MUST NOT ALREADY EXIST. # IF YOU USE THIS OPTION ON A MAILDIR THAT MAY BE ACCESSED BY # ANOTHER PROGRAM AT THE SAME TIME, STRANGE THINGS MAY HAPPEN. # # -U Preserve message UIDs in a Dovecot-compatible way # Looks for X-UID:, X-IMAP:, and X-IMAPbase: headers and # creates a Dovecot-compatible dovecot-uidlist file in # "destdir" # NOTE: NO LOCKING IS DONE AND THE FILE MUST NOT ALREADY EXIST. # IF YOU USE THIS OPTION ON A MAILDIR THAT MAY BE ACCESSED BY # ANOTHER PROGRAM AT THE SAME TIME, STRANGE THINGS MAY HAPPEN. # # -u Same as -U above, except creates a Courier IMAP-compatible # courierimapuiddb file instead. The only difference according # to http://wiki.dovecot.org/MailboxFormat/Maildir is that # Courier IMAP only stores the maildir file's basename # (everything before the colon) # NOTE: NO LOCKING IS DONE AND THE FILE MUST NOT ALREADY EXIST. # IF YOU USE THIS OPTION ON A MAILDIR THAT MAY BE ACCESSED BY # ANOTHER PROGRAM AT THE SAME TIME, STRANGE THINGS MAY HAPPEN. # # -S Add Maildir++ standard ,S= tag to the message filenames # indicating the size of the message on disk. This can be used # by Courier and Dovecot in calculating quotas. # I think Dovecot always uses this but not sure about Courier. # For Exim, see the quota_size_regex and maildir_tag config # statements. # # -W Add ,W= tag to the message filename indicating the RFC822.SIZE # of the message. This is the size of the message when actually # sent to an IMAP client with LF characters converted to CRLF # pairs as per the spec. Dovecot uses this to speed up returning # these sizes. Not sure if any other applications use it. # # -m If this is used then the source will # be the single mailbox at /var/spool/mail/blah for # user blah and the destination mailbox will be the # "destdir" mailbox itself. # # # -s source Directory or file relative to the user's home directory, # which is where the the "somefolders" directories are located. # Or if starting with a "/" it is taken as a # absolute path, e.g. /mnt/oldmail/user # # or # # A single mbox file which will be converted to # the destdir. # # -R If defined, do not skip directories found in a mailbox # directory, but runs recursively into each of them, # creating all wanted folders in Maildir. # Incompatible with '-f' # # -f somefolder Directories, relative to "sourcedir" where the Mbox files # are. All mailboxes in the "sourcedir" # directory will be converted and placed in the # "destdir" directory. (Typically the Inbox directory # which in this instance is also functioning as a # folder for other mailboxes.) # # The "somefolder" directory # name will be encoded into the new mailboxes' names. # See the examples below. # # This does not save an UW IMAP dummy message file # at the start of the Mbox file. Small changes # in the code could adapt it for looking for # other distinctive patterns of dummy messages too. # # Don't let the source directory you give as "somefolders" # contain any "."s in its name, unless you want to # create subfolders from the IMAP user's point of # view. See the example below. # # Incompatible with '-f' # # # -d destdir Directory where the Maildir format directories will be created. # If not given, then the destination will be ~/Maildir . # Typically, this is what the IMAP server sees as the # Inbox and the folder for all user mailboxes. # If this begins with a '/' the path is considered to be # absolute, otherwise it is relative to the users # home directory. # # -r strip_ext If defined this extension will be stripped from # the original mailbox file name before creating # the corresponding maildir. The extension must be # given without the leading dot ("."). See the example below. # # -l WU-file File containing the list of subscribed folders. If # migrating from WU-IMAP the list of subscribed folders will # be found in the file called .mailboxlist in the users # home directory. This will convert all subscribed folders # for a single user: # /bin/mb2md -s mail -l .mailboxlist -R -d Maildir # and for all users in a directory as root you can do the # following: # for i in *; do echo $i;su - $i -c "/bin/mb2md -s mail -l .mailboxlist -R -d Maildir";done |