I have a user who accidentially deleted a large number of emails prior to a certain date. He wants them back. I do have a tarfile backup of these messages. Is there a good way to restore them? Can I simply restore them to the appropriate Maildir directory and dovecot will just "figure it out"?
Thanks, --Mark
According to a message to this list from Oli Schacher, http://www.dovecot.org/list/dovecot/2011-June/059493.html, all I need to do is copy the deleted emails to their original folder and dovecot will take care of it:
On Tue Jun 7 08:43:54 EEST 2011 Oli Schacher wrote:
OK, but if I want to restore a particular mail from backups, what're the steps involved? What I mean is do I just copy and paste that mail file from backups to the user account maildir folder and what program should I run to synchronize 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.
Unless someone out there advises me against doing this, I'm going to try it.
I've also seen dovadm import
as a possible suggestion, though if a simple copy works I don't
see why anyone would use dovadm import
.
--Mark
-----Original Message----- From: Mark Foley mfoley@ohprs.org Date: Thu, 12 Nov 2015 17:13:50 -0500 To: dovecot@dovecot.org Subject: How to Restore emails
I have a user who accidentially deleted a large number of emails prior to a certain date. He wants them back. I do have a tarfile backup of these messages. Is there a good way to restore them? Can I simply restore them to the appropriate Maildir directory and dovecot will just "figure it out"?
Thanks, --Mark
Hi,
Mark Foley mfoley@ohprs.org (Do 12 Nov 2015 23:31:39 CET):
According to a message to this list from Oli Schacher, http://www.dovecot.org/list/dovecot/2011-June/059493.html, 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
-- SCHLITTERMANN.de ---------------------------- 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 ------------ -
Thanks for the reply Heiko
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.
--Mark
-----Original Message-----
Date: Thu, 12 Nov 2015 23:36:52 +0100 From: Heiko Schlittermann hs@schlittermann.de To: dovecot@dovecot.org Subject: Re: How to Restore emails
Hi,
Mark Foley mfoley@ohprs.org (Do 12 Nov 2015 23:31:39 CET):
According to a message to this list from Oli Schacher, http://www.dovecot.org/list/dovecot/2011-June/059493.html, 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
-- SCHLITTERMANN.de ---------------------------- 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 ------------ -
-----BEGIN PGP SIGNED MESSAGE----- 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@schlittermann.de To: dovecot@dovecot.org Subject: Re: How to Restore emails
Hi,
Mark Foley mfoley@ohprs.org (Do 12 Nov 2015 23:31:39 CET):
According to a message to this list from Oli Schacher, http://www.dovecot.org/list/dovecot/2011-June/059493.html, 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
-- SCHLITTERMANN.de ---------------------------- 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iQEVAwUBVkWal3z1H7kL/d9rAQLcOwgAkkQTsr3/G3Hx8ic7Dbt+rq6nMEqbtaLJ xv0S3YstOn4cfnadSCb3uWoAa3CGtdpS99dgr7U09Xyx6Jbq2WNElHgumVZVoJUz qffFhMHl//QVPDDEHvsHJTnjuQEpLo6QAnd/2Sq6pJ5zQ4hL6Nf6WSJkEZ15GB8V Zl9s9lnMDR3zEnKUzpFSAE4QVaM8PwByU91h2tc61Y+kVGFLrSJYfgfsLsNT+T4C dC4YhSa85Y8nHj9grpk/aY1f8QndThRpSxDixMuLeYphY/Nc8XljAn986+7wA72Z TszSvNrzNVz0qKxy7q+raTJ66bpxrlEwNCH9Fb33rC5Zk7WDwtfHAw== =cBzu -----END PGP SIGNATURE-----
On Fri, 13 Nov 2015 09:08:55 CET Steffen Kaiser wrote:
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).
I did shut down Dovecot before restoring the files.
The next problem comes with duplicates, because Maildir saves flags, keywords and status in the filename.
Good point. I was only restoring the ".Deleted Items" mail folder and sub-folder, so I wasn't too concerned with the flags since they shouldn't really be changing much for deleted messages. Still, you are right, it is possible that the user could have altered the flags on some of his deleted messages (since he's keeping these around for months essentially as another email archive).
I did a tar restore of that mail folder with the end-of-October full backup, and again with the incremental backup from the previous day. The user reported all message were restored OK. If he had changed flags he'd certainly end up with duplicates.
Next time I will restore to a temp directory and check the flags and not restore files with the same name but different flags.
--Mark
-----Original Message-----
Date: Fri, 13 Nov 2015 09:08:55 +0100 (CET) From: Steffen Kaiser skdovecot@smail.inf.fh-brs.de To: Mark Foley mfoley@ohprs.org Subject: Re: How to Restore emails Cc: dovecot@dovecot.org
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@schlittermann.de To: dovecot@dovecot.org Subject: Re: How to Restore emails
Hi,
Mark Foley mfoley@ohprs.org (Do 12 Nov 2015 23:31:39 CET):
According to a message to this list from Oli Schacher, http://www.dovecot.org/list/dovecot/2011-June/059493.html, 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
-- SCHLITTERMANN.de ---------------------------- 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
participants (3)
-
Heiko Schlittermann
-
Mark Foley
-
Steffen Kaiser