empress
empress copied to clipboard
Migrating INBOX
Related issues: #50, #52, #47
- Migrate using larch
--all
- Iterate over subfolders of INBOX using
doveadm mailbox list -u {{ email }} "INBOX.*"
- If a mailbox of the same name as that subfolder exists in the parent directory already (mailbox A), move all of the email inside of A into the subfolder (mailbox B), delete A, then move B up one directory
Note that some people actually have INBOX.INBOX
. If this is found, skip it and all subfolders of INBOX.INBOX
.
Relevant documentation:
- http://wiki2.dovecot.org/Tools/Doveadm/Mailbox
- http://wiki2.dovecot.org/Tools/Doveadm/Search
- http://wiki2.dovecot.org/Tools/Doveadm/Move
Example: List info about all top-level mailboxes
This will show how the size of all top-level folders and how many messages are in them:
doveadm mailbox list -u [email protected] \
| grep -v "INBOX." \
| xargs -I {} doveadm mailbox status -u [email protected] "messages vsize guid" {}
Example: Move messages in root folders into corresponding INBOX. folders
Note that this command skips the messages in INBOX
(unlike the previous example) as it does grep -v "INBOX"
instead of grep -v "INBOX."
.
The sed
command is used to handle folders with spaces in their name.
[email protected]
doveadm mailbox list -u $EMAIL \
| grep -v "INBOX" \
| xargs -I {} doveadm mailbox status -u $EMAIL messages {} \
| grep -v "messages=0" \
| sed -n 's/\(.*\) messages=.*/\1/p' \
| xargs -I {} doveadm move -u $EMAIL "INBOX.{}" mailbox "{}" ALL
Note the quotes around "INBOX.{}" and "{}"! These are important to handle mailboxes with spaces!
Important note on use of separators!
The example at the bottom here indicates that the folder separator may be a variable, so it's best to write these scripts like "INBOX${SEP}{}"
instead of assuming it's .
as in "INBOX.{}"
Relevant links on where this setting is stored:
- http://wiki.dovecot.org/Namespaces
- http://wiki.dovecot.org/UserDatabase/ExtraFields
In my case the separator was stored like so:
$ doveconf -S namespace/inbox/separator
namespace/inbox/separator=
$ doveconf -S namespace/default/separator
# empty results, nothing returned
Where doveconf -S namespace
returned:
namespace=inbox
namespace/inbox/name=inbox
namespace/inbox/type=private
namespace/inbox/separator=
... [snip] ...
The file /etc/dovecot/conf.d/10-mail.conf
states:
The default however depends on the underlying mail storage format.
And the rules for that are outlined here, and apparently there are two types of separators ("layout" and "namespace" separators).