Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Migrating INBOX #60

Open
taoeffect opened this issue Dec 2, 2014 · 3 comments
Open

Migrating INBOX #60

taoeffect opened this issue Dec 2, 2014 · 3 comments

Comments

@taoeffect
Copy link
Owner

taoeffect commented Dec 2, 2014

Related issues: #50, #52, #47

  1. Migrate using larch --all
  2. Iterate over subfolders of INBOX using doveadm mailbox list -u {{ email }} "INBOX.*"
  3. 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.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6711400-migrating-inbox?utm_campaign=plugin&utm_content=tracker%2F8064840&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F8064840&utm_medium=issues&utm_source=github).
@taoeffect
Copy link
Owner Author

Relevant documentation:

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 user@domain.com \
    | grep -v "INBOX." \
    | xargs -I {} doveadm mailbox status -u user@domain.com "messages vsize guid" {}

@taoeffect
Copy link
Owner Author

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=user@domain.com
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!

@taoeffect
Copy link
Owner Author

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:

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant