Recovering deleted mailbox

Shawn Heisey elyograg at
Wed Apr 27 22:57:37 UTC 2022

On 4/27/22 16:18, Sean McBride wrote:
> I have a user (coworker) that accidentally deleted a mailbox and all its sub-mailboxes.
> I use Maildir format storage.  I have backups.
> Is it enough to put the mailbox folder back where it was?  I'm talking about the folder that contains 'cur', 'new', 'tmp', 'dovecot-uidlist', etc.   Or would this desynchronize or otherwise confuse dovecot?  Or is it preferable to use some doveadm command?  Or...?

Disclaimer:  I am not affiliated with the project, and I am definitely 
not an expert.  I've been running dovecot for my personal mail server 
for a long time, thankfully with very few incidents.  I have done some 
manual surgery on my maildir mailbox and seen how it reacts.  Dovecot is 
very resilient.

What you describe should be sufficient.  It's how I would proceed with a 
restore.  In most cases I would copy the backup on top of any existing 
structure, rather than doing a wholesale replace, because any new mail 
received should have different filenames than what is in the backup.

If it were me, I would probably delete all the files that have a 
filename starting with "dovecot" in that user's mailbox, and restart 
dovecot, letting dovecot rebuild those files when the user connects.  I 
don't really have any experience with how things operate over POP3, I've 
always used IMAP with dovecot.

I'm interested to know whether the real experts here have different 
advice than this, in case I ever find myself in that situation.  There 
might be some doveadm commands that accomplish the dovecot* file 
rebuilding in a cleaner way.


More information about the dovecot mailing list