Re: How to Restore emails

2015-11-13 Thread Steffen Kaiser

-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 
To: dovecot@dovecot.org
Subject: Re: How to Restore emails

Hi,

Mark Foley  (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-


Re: How to Restore emails

2015-11-13 Thread Mark Foley
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 
> To: Mark Foley 
> 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 
> >> To: dovecot@dovecot.org
> >> Subject: Re: How to Restore emails
> >>
> >> Hi,
> >>
> >> Mark Foley  (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