[Dovecot] Deleting a mailbox and all its children

Timo Sirainen tss at iki.fi
Wed Nov 16 03:15:02 EET 2011


On 16.11.2011, at 3.04, Micah Anderson wrote:

> I'm looking at scripting a mechanism to delete a mailbox, which is easy
> with 'doveadm mailbox delete' -- however it gets complicated when there
> are children of arbitrary depth, for example, I may have this:
> 
> restored.daily1.INBOX
> restored.daily1.Sent
> restored.daily1.Mystuff
> restored.daily1.Mystuff.foo
> 
> I would like to delete the 'restored' mailbox and all its children (and
> unsubscribe the folders), but the 'doveadm mailbox delete' command wont
> delete any children.
> 
> I'm surprised that there isn't a -r (recursive) option to 'doveadm
> mailbox delete', but perhaps I am missing the easier way to handle this?

Well, how about something like:

doveadm mailbox list 'restored.*' | xargs -1 doveadm mailbox delete
doveadm mailbox delete restored

That's what it would have to do internally anyway..




More information about the dovecot mailing list