Re: Retrieving mail from read-only mdbox

2017-06-05 Thread Teemu Huovila


On 01.06.2017 00:30, Mark Moseley wrote:
> This is a 'has anyone run into this and solved it' post. And yes, I've been
> reading and re-reading TFM but without luck. The background is that I'm
> working on tooling before we start a mass maildir->mdbox conversion. One of
> those tools is recovering mail from backups (easy as pie with maildir).
> 
> We've got all of our email on Netapp file servers. They have nice
> snapshotting but the snapshots are, of course, readonly.
> 
> My question: is there a doveadm command that will allow for email to be
> retrieved from a readonly mdbox, either directly (like manipulating the
> mdbox files directly) or by doveadm talking to the dovecot processes?
What would this tooling do exactly? Is it for restoring the users existing 
(writable) account from a read-only backup? I would in that case recommend 
looking into using "doveadm backup" or "doveadm sync". They do provide som 
crude selection of messages on e.g. folder level.

In case you you are aiming to provide users online access to their own backups, 
maybe add them as a read-only mailbox using ACLs. Though other mails in this 
thread indicate there still might be problems.

br,
Teemu

> 
> Ideally, there'd be something like doveadm dump, but that could dump
> selected message contents.
> 
> I've tried using IMAP with mail_location pointed at the snapshot, but,
> though I can get a listing of emails in the mailbox, the fetch fails when
> dovecot can't write-lock dovecot.index.log.
> 
> If anyone has gotten something similar to work, I'd love to hear about it.
> A working IMAP setup would be the ideal, since it's more easily automatible
> (but I'll take whatever I can get).
> 
> Any and all hints are most welcome!
> 


Re: Retrieving mail from read-only mdbox

2017-06-01 Thread Peter Benko
>This is a 'has anyone run into this and solved it' post. And yes, I've been
>reading and re-reading TFM but without luck. The background is that I'm
>working on tooling before we start a mass maildir->mdbox conversion. One of
>those tools is recovering mail from backups (easy as pie with maildir).
>
>We've got all of our email on Netapp file servers. They have nice
>snapshotting but the snapshots are, of course, readonly.
>
>My question: is there a doveadm command that will allow for email to be
>retrieved from a readonly mdbox, either directly (like manipulating the
>mdbox files directly) or by doveadm talking to the dovecot processes?
>
>Ideally, there'd be something like doveadm dump, but that could dump
>selected message contents.
>
>I've tried using IMAP with mail_location pointed at the snapshot, but,
>though I can get a listing of emails in the mailbox, the fetch fails when
>dovecot can't write-lock dovecot.index.log.
>
>If anyone has gotten something similar to work, I'd love to hear about it.
>A working IMAP setup would be the ideal, since it's more easily automatible
>(but I'll take whatever I can get).
>
>Any and all hints are most welcome!

Hi Mark,

I had exactly the same problem as you. I also tried to put the INDEX to a 
writeable fs (also to MEMORY) but it did not work. What I did in the end is 
that I created a writeable version of my read-only snapshot using AuFS. This 
way I was able to access the snapshot over IMAP and destroy the AuFS mount when 
finished.

It's not a perfect solution, but it works :)

Regards,

Peter


Re: Retrieving mail from read-only mdbox

2017-06-01 Thread Mark Moseley
On Wed, May 31, 2017 at 3:24 PM, M. Balridge  wrote:

> Quoting Mark Moseley :
>
> > I've tried using IMAP with mail_location pointed at the snapshot, but,
> > though I can get a listing of emails in the mailbox, the fetch fails when
> > dovecot can't write-lock dovecot.index.log.
>
> I'm surprised that dovecot would even try to write-lock a write-protected
> file/directory, though I can appreciate the situation where a file may be
> in a
> directory that is writable by some UID other than the one dovecot is
> running as.
>
> Is there an unsafe control over lock_method similar to Samba's fake oplocks
> setting in Dovecot?
>
> If anyone wants some good "horror" writing, a perusal of Jeremy Allison's
> write-up on the schizophrenic approaches to file-locking is worthy of your
> time.
>
> https://www.samba.org/samba/news/articles/low_point/tale_two_stds_os2.html
>
>
>
There's no fake locks from what I can tell. If I'm reading the source
right, the only valid options are fcntl, flock, and dotlock.
Tried 'em all :)


Re: Retrieving mail from read-only mdbox

2017-06-01 Thread Mark Moseley
>
> >
> > > I've tried using IMAP with mail_location pointed at the snapshot, but,
> > > though I can get a listing of emails in the mailbox, the fetch fails
> when
> > > dovecot can't write-lock dovecot.index.log.
> >
> > I've thought about doing this someday (adding snapshots to a user's
> > namespace) but never got around to doing it.  Snapshots get rotated
> > (e.g. hourly.1 -> hourly.2 -> etc.)  so every hour, so any indices
> > produced gets invalidated.  You would need to generate MEMORY indices
> > to create it on the fly.  Something like
> >
> >   namespace snapshots {
> >   location = ...:INDEX==MEMORY
> >   ...
> >   }
> >
> > I'm not sure how dovecot would react when NetApp pulls the rug out
> > from under one of the hourly snapshots and replace it with the next
> > hour's version.
> >
> > Joseph Tam 
>
> location=...:INDEX=MEMORY, actually.
>
> When the rug gets pulled, what happens, depends on whether the user has
> the snapshots location open or not, but it would probably kick the user out
> in the end and complain. But then the user would probably reconnect? =)
>
>

I didn't want to muddy the waters in my first message with all the stuff
I've tried, but that was one of them. On our existing maildir mailboxes, we
have INDEX pointed at a local SSD, so that was one of the first things I
tried. For this readonly mdbox, I tried pointing INDEX= at a local disk, as
well as MEMORY. I've also got CONTROL= set to local disk as well for this.

However (and I assumed that this was probably due to the nature of mdbox
and a known thing), if I set INDEX to anything (MEMORY or a path) on my
mdbox mailboxes, dovecot acts as if the mailbox is empty. I've tried every
permutation I can think of, but the end result is this: without INDEX=, I
can get a list of messages (still can't FETCH due to the index); if I add
INDEX=, I get no results. Debug output with INDEX shows that auth is ok,
the index is being picked up correctly and that the mail_location is still
correct.

I notice too that when I have INDEX set to a path, when I strace the imap
process, though it stat()s the mail_location, it never once tries to stat()
or open any of the storage files under the mail_location. It *does* stat()
the 'storage' directory inside the snapshot, but never walks that directory
nor stat()s the m.# files inside of it.

If I have INDEX set to MEMORY, as of 2.2.30 (I didn't see this with 2.2.27,
though I still got an empty mailbox result), I get a traceback in the logs:

Jun 01 14:10:06 imap-login: Info: Login: user=,
method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=8542, secured,
session=
Jun 01 14:10:06 imap(md...@test.com): Panic: file mailbox-list.c: line
1330: unreached
Jun 01 14:10:06 imap(md...@test.com): Error: Raw backtrace:
/usr/lib/dovecot/libdovecot.so.0(+0x9d9e2) [0x6b2dd043f9e2] ->
/usr/lib/dovecot/libdovecot.so.0(+0x9dacd) [0x6b2dd043facd] ->
/usr/lib/dovecot/libdovecot.so.0(i_fatal+0) [0x6b2dd03d1821] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mailbox_list_get_root_forced+0x51)
[0x6b2dd0721891] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mdbox_map_init+0x28)
[0x6b2dd07376b8] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mdbox_storage_create+0xeb)
[0x6b2dd073e2cb] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mail_storage_create_full+0x3d4)
[0x6b2dd0714884] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mail_storage_create+0x2c)
[0x6b2dd0714c2c] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mail_namespaces_init_add+0x159)
[0x6b2dd070ac09] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mail_namespaces_init+0xd9)
[0x6b2dd070bd99] -> dovecot/imap [md...@test.com 127.0.0.1]() [0x426a10] ->
/usr/lib/dovecot/libdovecot.so.0(+0x37783) [0x6b2dd03d9783] ->
/usr/lib/dovecot/libdovecot.so.0(+0x37a4d) [0x6b2dd03d9a4d] ->
/usr/lib/dovecot/libdovecot.so.0(+0x383da) [0x6b2dd03da3da] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x52) [0x6b2dd0454c42] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run_internal+0x109)
[0x6b2dd04562b9] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x3c) [0x6b2dd0454cdc]
-> /usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x38) [0x6b2dd0454e88] ->
/usr/lib/dovecot/libdovecot.so.0(master_service_run+0x13) [0x6b2dd03dbd93]
-> dovecot/imap [md...@test.com 127.0.0.1](main+0x302) [0x40caa2] ->
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x6b2dcfff9830] ->
dovecot/imap [md...@test.com 127.0.0.1](_start+0x29) [0x40cc29]
Jun 01 14:10:06 imap(md...@test.com): Fatal: master: service(imap): child
8542 killed with signal 6 (core dumps disabled)

But again, I figured that maybe this was normal for mdbox (or that I've
goofed something else up). Also, the 'If I set index, the mailbox is empty
or I get a traceback' happens if I'm looking at a readonly mdbox or a
regular, writable mdbox (and the writable one works perfectly if you remove
INDEX=).

BTW, in my case, the 'snapshot' IMAP wouldn't be directly accessible to end

Re: Retrieving mail from read-only mdbox

2017-05-31 Thread Aki Tuomi

> On June 1, 2017 at 4:05 AM Joseph Tam  wrote:
> 
> 
> 
> > I've tried using IMAP with mail_location pointed at the snapshot, but,
> > though I can get a listing of emails in the mailbox, the fetch fails when
> > dovecot can't write-lock dovecot.index.log.
> 
> I've thought about doing this someday (adding snapshots to a user's
> namespace) but never got around to doing it.  Snapshots get rotated
> (e.g. hourly.1 -> hourly.2 -> etc.)  so every hour, so any indices
> produced gets invalidated.  You would need to generate MEMORY indices
> to create it on the fly.  Something like
> 
>   namespace snapshots {
>   location = ...:INDEX==MEMORY
>   ...
>   }
> 
> I'm not sure how dovecot would react when NetApp pulls the rug out
> from under one of the hourly snapshots and replace it with the next
> hour's version.
> 
> Joseph Tam 

location=...:INDEX=MEMORY, actually.

When the rug gets pulled, what happens, depends on whether the user has the 
snapshots location open or not, but it would probably kick the user out in the 
end and complain. But then the user would probably reconnect? =)

Aki


Re: Retrieving mail from read-only mdbox

2017-05-31 Thread Joseph Tam



I've tried using IMAP with mail_location pointed at the snapshot, but,
though I can get a listing of emails in the mailbox, the fetch fails when
dovecot can't write-lock dovecot.index.log.


I've thought about doing this someday (adding snapshots to a user's
namespace) but never got around to doing it.  Snapshots get rotated
(e.g. hourly.1 -> hourly.2 -> etc.)  so every hour, so any indices
produced gets invalidated.  You would need to generate MEMORY indices
to create it on the fly.  Something like

namespace snapshots {
location = ...:INDEX==MEMORY
...
}

I'm not sure how dovecot would react when NetApp pulls the rug out
from under one of the hourly snapshots and replace it with the next
hour's version.

Joseph Tam 


Re: Retrieving mail from read-only mdbox

2017-05-31 Thread M. Balridge
Quoting Mark Moseley :

> I've tried using IMAP with mail_location pointed at the snapshot, but,
> though I can get a listing of emails in the mailbox, the fetch fails when
> dovecot can't write-lock dovecot.index.log.

I'm surprised that dovecot would even try to write-lock a write-protected
file/directory, though I can appreciate the situation where a file may be in a
directory that is writable by some UID other than the one dovecot is running as.

Is there an unsafe control over lock_method similar to Samba's fake oplocks
setting in Dovecot?

If anyone wants some good "horror" writing, a perusal of Jeremy Allison's
write-up on the schizophrenic approaches to file-locking is worthy of your time.

https://www.samba.org/samba/news/articles/low_point/tale_two_stds_os2.html

=M=


Retrieving mail from read-only mdbox

2017-05-31 Thread Mark Moseley
This is a 'has anyone run into this and solved it' post. And yes, I've been
reading and re-reading TFM but without luck. The background is that I'm
working on tooling before we start a mass maildir->mdbox conversion. One of
those tools is recovering mail from backups (easy as pie with maildir).

We've got all of our email on Netapp file servers. They have nice
snapshotting but the snapshots are, of course, readonly.

My question: is there a doveadm command that will allow for email to be
retrieved from a readonly mdbox, either directly (like manipulating the
mdbox files directly) or by doveadm talking to the dovecot processes?

Ideally, there'd be something like doveadm dump, but that could dump
selected message contents.

I've tried using IMAP with mail_location pointed at the snapshot, but,
though I can get a listing of emails in the mailbox, the fetch fails when
dovecot can't write-lock dovecot.index.log.

If anyone has gotten something similar to work, I'd love to hear about it.
A working IMAP setup would be the ideal, since it's more easily automatible
(but I'll take whatever I can get).

Any and all hints are most welcome!