how to add, merge, recover individual IMAP messages

I've newly implemented IMAP mail folders on our Slackware64 14.1 server. I'm used to the 'ole mbox format and am new to IMAP. With mbox, if I wanted to add one or more message to a mbox I could simply cat >> the messages to the mbox file and voila!, there were in there.  It does not appear to quite work this way with IMAP what with indexes and all.

How would a add a message (for example, an accidental deletion) to an IMAP folder?
LVL 1
jmarkfoleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan SpringerCommented:
IMAP has nothing to do with file format.  IMAP is a method of retrieval.

It sounds as if you're using Maildir format (one message per file).

What was the original file name of the message that was deleted?  That's what you'll use to recreate it.  Make sure to set the ownership, permissions and any selinux perms.
0
jmarkfoleyAuthor Commented:
Well, I thought IMAP implied Maildir and visa-versa.

Yes, I have both the original name and original mail file from backups. I've tried simply copying the file to the proper location in the Maildir hierarchy, but didn't see it in my mail clients (Outlook, and RoundCube). Should I have? Is that all there is to it? Maybe I fooped something in my restore.
0
Jan SpringerCommented:
nope.

are you running selinux?  have you set all of the proper permissions?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jmarkfoleyAuthor Commented:
"Nope" to which question?

I am running Slackware64 14.1, The local delivery agent is procmail 3.22. $HOME/.procmailrc has:

ORGMAIL=${HOME}/Maildir/
DEFAULT=${ORGMAIL}

permission should not be an issue since any "restore" would be done as root. Of course, I would restore as the user.group of the appropriate owner.
0
Jan SpringerCommented:
nope = IMAP does not imply Maildir.

usually the same app is used for both IMAP and POP (i.e., dovecot).

the mailbox type is independent of the protocol.

i am running dovecot, use IMAP to retrieve my mail which is in mbox format.
0
jmarkfoleyAuthor Commented:
Ok, but I'm not asking about IMAP versus POP versus Maildir. I have Maildir folders. Do youu know how to recover messages/folder for Maildir?
0
Jan SpringerCommented:
Does your backup/restore software not offer the option to restore by filename back into the original directory from which it was backed up?
0
jmarkfoleyAuthor Commented:
Yes, but I didn't think that would work. I tried doing an entire folder and didn't see it. Maybe I tried a 'special' Outlook folder like 'Deleted Items'. I'll try again and post results.
0
jmarkfoleyAuthor Commented:
I've done some experimenting. I was able to restore an individual message to the Maildir hierarchy. However, when I deleted (through Outlook, not by `rm`) a mail folder, then restored it, it does not show up in either Outlook or RoundCube webmail. That's exactly what I saw before -- mail folders not restoring.

There are several Dovecot files in the Maildir directory:
$ ls -la /home/HPRS/mark/Maildir/
total 180
drwx------ 13 mark users  4096 2015-03-08 13:42 ./
drwxr-xr-x  3 mark users  4096 2015-03-03 00:08 ../
drwx------  5 mark users  4096 2015-03-08 13:39 .Deleted\ Items/
drwx------  5 mark users  4096 2015-02-13 22:30 .Enrollment\ Files/
drwx------  5 mark users  4096 2015-03-06 10:48 .Junk\ E-mail/
drwx------  5 mark users  4096 2015-03-01 18:45 .Notes/
drwx------  5 mark users  4096 2015-03-03 12:19 .Sent\ Items/
drwx------  5 mark users  4096 2015-03-02 10:37 .Trash/
drwx------  5 mark users  4096 2015-03-03 02:10 .contact\ spam/
drwx------  5 mark users  4096 2015-03-03 02:10 .contact\ spam/
drwx------  5 mark users  4096 2015-02-28 13:39 .matkeson\ testing/
drwx------  2 mark users 12288 2015-03-08 13:42 cur/
-rw-------  1 mark users  5543 2015-03-08 09:18 dovecot-uidlist
-rw-------  1 mark users     8 2015-03-01 18:45 dovecot-uidvalidity
-r--r--r--  1 mark users     0 2015-01-16 23:02 dovecot-uidvalidity.54b9deef
-rw-------  1 mark users  1880 2015-03-01 18:46 dovecot.index
-rw-------  1 mark users 64064 2015-03-08 13:40 dovecot.index.cache
-rw-------  1 mark users 23700 2015-03-08 13:42 dovecot.index.log
-rw-------  1 mark users  1344 2015-03-08 13:39 dovecot.mailbox.log
drwx------  2 mark users  4096 2015-03-08 09:18 new/
-rw-------  1 mark users    79 2015-03-08 13:39 subscriptions
drwx------  2 mark users  4096 2015-03-08 09:17 tmp/

Open in new window

Do you think that removing an entire mail folder affects these dovecot indexes and can not simply be restored directly?

btw - the '.matkeson testing' folder is the one I deleted/restored
0
Jan SpringerCommented:
did it restore it to the cur directory?
0
jmarkfoleyAuthor Commented:
In the `ls -ltr` in my previous message there is a ./cur directory and yes, that directory was restored. The Maildir/cur directory has no folders itself and I assume that must be the inbox. All the folders are subordinate to Maildir and each have their own ./cur
0
Jan SpringerCommented:
have you tried copying it into the main cur folder (inbox) and set the appropriate permissions?
0
jmarkfoleyAuthor Commented:
Interesting phenomenon: I noticed in RoundCube webmail > Settings > Folders, that this "restored" folder was listed, but "Subscribed" was un-checked. I check that box and the folder showed up in both RoundCube and Outlook.

While I wouldn't expect Outlook to have such a feature, I suppose I could use RoundCube as a work-around to make restored folders visible, but it seems to me there should be a way to do this in Dovecot after restoring a folder from backup.

Ideas?
0
Jan SpringerCommented:
there are dovecot files that identify the data regarding the messages.  if you were to delete those forcing a rebuild (particularly the log and cache files), it may cause the new folder to appear.
0
jmarkfoleyAuthor Commented:
According to this link: http://comments.gmane.org/gmane.mail.imap.dovecot/55399 answered by Timo Sirainen himself (2 one-word answers),
> Here's an easy question for you.  I'm restoring some emails from a backup.  Do I need to delete or otherwise manually rebuild the indexes?

No.

> Or will Dovecot itself detect that something is amiss and handle it on first folder access?

Yep.
This implies that there is nothing to do (or even can be done?) on the Dovecot side. It will do its thing when the folder is accessed. The tricky bit is "handle it on first folder access". While RoundCube does have a mechanism to "subscribe" to this restored/unsubscribed folder, Outlook doesn't appear to see this folder and I don't believe that Outlook has a similar mechanism.

Do you know any way of making this folder appear by something from the Outlook client?

As to your suggestion about "deleting [dovecot] files that identify the data ...". That would be guesswork on my part and I feel much less confident doing that than using the RoundCube trick on that future, hopefully occasion when I might have to restore someone's folder(s).
0
Jan SpringerCommented:
Timo writes and updates the dovecot software.  He is the ultimate authority.

I think what you're asking here is an Outlook question -- an app I've never used.

According to Timo, you don't need to delete those files for a restore.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmarkfoleyAuthor Commented:
Jan Springer
I think what you're asking here is an Outlook question
Yes, I think so. If TImo says "no problem" with respect to dovecot, and RoundCube handles it without problem, then I think this must be an Outlook thing (an app I wish we didn't use!)
0
jmarkfoleyAuthor Commented:
I'll munge and repost for Outlook
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.