How to Restore emails

Steffen Kaiser skdovecot at
Fri Nov 13 08:08:55 UTC 2015

Hash: SHA1

On Thu, 12 Nov 2015, Mark Foley wrote:

>> About the 'cur' I'd not be too sure.
> Well, I'm just restoring to .Deleted Items, so it shouldn't be a problem. The tar restore
> should preserve names, permission, etc. I'll backup the current Maildir, the try the restore
> and see what happens. I'll report back.

a problem will arise, if Dovecot indexes the directory when the file is 
not fully restorred, hence, changes later.

Therefore, either prevent any access in Dovecot (deliver and retrieval) or 
use Heiko's approach, because mv is atomic on the same filesystem (rename 
instead of copy).

The next problem comes with duplicates, because Maildir saves flags, 
keywords and status in the filename.

I, therefore, copy a backup to another subdir, say "tmp2", then run fdupes 
(or similiar program) over cur, new and tmp2 to find duplicates, delete 
them in tmp2, and finally "mv -i " (you never know ;-) ) the remaining 
files from tmp2 to cur or new.

> -----Original Message-----
>> Date: Thu, 12 Nov 2015 23:36:52 +0100
>> From: Heiko Schlittermann <hs at>
>> To: dovecot at
>> Subject: Re: How to Restore emails
>> Hi,
>> Mark Foley <mfoley at> (Do 12 Nov 2015 23:31:39 CET):
>>> According to a message to this list from Oli Schacher,
>>>, all I need to do is copy the deleted
>>> emails to their original folder and dovecot will take care of it:
>> ???
>>>> exactly, just copy the mail from your backup back into the users
>>>> maildir (usually into 'cur'). Make sure the permissions of the restored
>>>> file are correct. No need to synchronize anything, dovecot automatically
>>>> detects the added message.
>> About the 'cur' I'd not be too sure. If you *mv* the files there from a
>> directory on the same filesystem, you should be fine, but if copy the
>> files, I'd be careful. Probably you want to mimic the maildir behaviour:
>>     copy the files to tmp/
>>     mv the files to cur/     (not sure, if new/ would be fine to,
>>                               because new/ is the natural place after
>>                               tmp/. I'm not sure, what this does to the
>>                               message state the client sees.)
>>     Best regards from Dresden/Germany
>>     Viele Grüße aus Dresden
>>     Heiko Schlittermann
>> --
>> ---------------------------- internet & unix support -
>>  Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
>>  gnupg encrypted messages are welcome --------------- key ID: F69376CE -
>>  ! key id 7CBF764A and 972EAC9F are revoked since 2015-01 ------------ -

- -- 
Steffen Kaiser
Version: GnuPG v1


More information about the dovecot mailing list