Recovering deleted mailbox
Hi all,
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...?
Thanks,
Sean
I've done so with no issues as long as permissions and ownership are accurate.
Ted Hatfield
On Wed, 27 Apr 2022, Sean McBride wrote:
Hi all,
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...?
Thanks,
Sean
Well, I finally had time to try this (with a test account) and it did not work for me.
I restored the .mailboxname folder (and all its contents, and with permissions preserved) and even ran:
sudo doveadm force-resync -u testuser mailboxname
but I don't see the folder restored from my IMAP client (roundcube).
Anyone have any suggestions?
Thanks,
Sean
On 27 Apr 2022, at 18:53, Ted Hatfield wrote:
I've done so with no issues as long as permissions and ownership are accurate.
Ted Hatfield
On Wed, 27 Apr 2022, Sean McBride wrote:
Hi all,
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...?
Thanks,
Sean
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.
Thanks, Shawn
On 28/04/2022 01:57 Shawn Heisey elyograg@elyograg.org wrote:
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.
Thanks, Shawn
There is no reason to delete the dovecot files after recovery. You can run doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.
Aki
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.
Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW
# WITHOUT GOOD REASON
#
DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>"
service dovecot stop
curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}"
find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f
service dovecot start
doveadm index -A -q '*'
-s
On 28/04/2022 08:33 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW # WITHOUT GOOD REASON # DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>" service dovecot stop curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}" find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f service dovecot start doveadm index -A -q '*'-s
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
Aki
On 4/27/2022 11:48 PM, Aki Tuomi wrote:
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
I do full reindexes a lot more often than a typical user would. When I do a reindex, I want it to happen for all users, not one at a time. Do you have a sequence of commands to accomplish that?
I'm part of the Solr project. I do reindexes for performance testing when I think of something to try, or I want to upgrade Solr. And also when I think of a change that I want to make to the index config for dovecot. A full reindex for my install takes less than 10 minutes as I only have about 160K messages total. Not something I would recommend doing frequently when there are millions of messages.
Thanks, Shawn
On 28/04/2022 08:57 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:48 PM, Aki Tuomi wrote:
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
I do full reindexes a lot more often than a typical user would. When I do a reindex, I want it to happen for all users, not one at a time. Do you have a sequence of commands to accomplish that?
I'm part of the Solr project. I do reindexes for performance testing when I think of something to try, or I want to upgrade Solr. And also when I think of a change that I want to make to the index config for dovecot. A full reindex for my install takes less than 10 minutes as I only have about 160K messages total. Not something I would recommend doing frequently when there are millions of messages.
Thanks, Shawn
Then I would recommend using curl to drop all indexes from solr, and then run doveadm index -A -q '*'
as you are doing already.
Aki
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 7:48, Aki Tuomi ha escrit:
On 28/04/2022 08:33 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW # WITHOUT GOOD REASON # DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>" service dovecot stop curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}" find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f service dovecot start doveadm index -A -q '*'-s
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
Aki
I took note of this: # Repair doveadm -v force-resync -u $User '*' # Drop fts data doveadm -v fts rescan -u $User # Rebuild index doveadm -v index -u $User '*'
But I'm not clear about $User it it's for my system "vmail" account that run Dovecot services, or it refers to mail account. In first case, how to specify mail account or maildir tree to act to?
Thank you.
On 28/04/2022 09:56 Narcis Garcia debianlists@actiu.net wrote:
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 7:48, Aki Tuomi ha escrit:
On 28/04/2022 08:33 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW # WITHOUT GOOD REASON # DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>" service dovecot stop curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}" find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f service dovecot start doveadm index -A -q '*'-s
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
Aki
I took note of this: # Repair doveadm -v force-resync -u $User '*' # Drop fts data doveadm -v fts rescan -u $User # Rebuild index doveadm -v index -u $User '*'
But I'm not clear about $User it it's for my system "vmail" account that run Dovecot services, or it refers to mail account. In first case, how to specify mail account or maildir tree to act to?
Thank you.
It refers to user's mail account, not system vmail account.
Aki
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 8:57, Aki Tuomi ha escrit:
On 28/04/2022 09:56 Narcis Garcia debianlists@actiu.net wrote:
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 7:48, Aki Tuomi ha escrit:
On 28/04/2022 08:33 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW # WITHOUT GOOD REASON # DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>" service dovecot stop curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}" find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f service dovecot start doveadm index -A -q '*'-s
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
Aki
I took note of this: # Repair doveadm -v force-resync -u $User '*' # Drop fts data doveadm -v fts rescan -u $User # Rebuild index doveadm -v index -u $User '*'
But I'm not clear about $User it it's for my system "vmail" account that run Dovecot services, or it refers to mail account. In first case, how to specify mail account or maildir tree to act to?
Thank you.
It refers to user's mail account, not system vmail account.
Aki
And "doveadm -v fts rescan -u $MailAccount" how it's specified mailbox(es)? '*' or the only syntax if for all?
On 28/04/2022 10:00 Narcis Garcia debianlists@actiu.net wrote:
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 8:57, Aki Tuomi ha escrit:
On 28/04/2022 09:56 Narcis Garcia debianlists@actiu.net wrote:
I'm using this dedicated address because personal addresses aren't masked enough at this mail public archive. Public archive administrator should fix this against automated addresses collectors. El 28/4/22 a les 7:48, Aki Tuomi ha escrit:
On 28/04/2022 08:33 Shawn Heisey elyograg@elyograg.org wrote:
On 4/27/2022 11:27 PM, Aki Tuomi wrote:
There is no reason to delete the dovecot files after recovery. You can run
doveadm force-resync
to ensure everything is synced. Removing the files just cause more problems than benefit usually.Thanks for that information! Very helpful for future fiddling.
Does that resync command also maybe force a full FTS reindex? I'm using fts_solr. The way that I currently manage a full reindex is with the following shell script:
#!/bin/sh DOVECOT_SOLR_URL_BASE="http://localhost:8983/solr/dovecot" MAIL_ROOT=/var/vmail
# DO NOT MODIFY BELOW # WITHOUT GOOD REASON # DEL_ALL_QUERY_XML="<delete><query>*:*</query></delete>" service dovecot stop curl
"${DOVECOT_SOLR_URL_BASE}/update?commit=true&optimize=true"
-H "Content-Type: text/xml"
--data-binary "${DEL_ALL_QUERY_XML}" find ${MAIL_ROOT} -name "dovecot.*index*" -print0 | xargs -0 rm -f service dovecot start doveadm index -A -q '*'-s
# drop fts data doveadm fts rescan -u user # rebuild index doveadm index -u user "*"
Aki
I took note of this: # Repair doveadm -v force-resync -u $User '*' # Drop fts data doveadm -v fts rescan -u $User # Rebuild index doveadm -v index -u $User '*'
But I'm not clear about $User it it's for my system "vmail" account that run Dovecot services, or it refers to mail account. In first case, how to specify mail account or maildir tree to act to?
Thank you.
It refers to user's mail account, not system vmail account.
Aki
And "doveadm -v fts rescan -u $MailAccount" how it's specified mailbox(es)? '*' or the only syntax if for all?
You can specify namespace prefix if necessary. It will clean out FTS indexes for the specified namespace.
Aki
On 2022-04-28 09:00, Narcis Garcia wrote:
export MailAccount="user@example.org" && doveadm -v fts rescan -u $MailAccount
And "doveadm -v fts rescan -u $MailAccount" how it's specified mailbox(es)? '*' or the only syntax if for all?
for sql backends
# syntax for posgresql with postfixadmin database iterate_query = SELECT username AS user FROM postfix_mailbox WHERE active = '1'
this makes -A to do all users not just -u $MailAccount
hope this helps
participants (6)
-
Aki Tuomi
-
Benny Pedersen
-
Narcis Garcia
-
Sean McBride
-
Shawn Heisey
-
Ted Hatfield