Zimbra Restore Mails From Store Folder: Difference between revisions
No edit summary |
|||
| (3 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Zimbra]] | |||
== Zimbra Mailbox Structure == | == Zimbra Mailbox Structure == | ||
In Zimbra, each user is assigned a unique 'mailbox ID', which links him/her to their folder in ''/opt/zimbra/store/0''. | In Zimbra, each user is assigned a unique 'mailbox ID', which links him/her to their folder in ''/opt/zimbra/store/0''. | ||
| Line 35: | Line 37: | ||
# /opt/zimbra/store.old/0/findusers.sh | # /opt/zimbra/store.old/0/findusers.sh | ||
This will return a list of top ten users (in '''/tmp/messagelist''') whose name is present in the 'To:' field of the messages stored. | This will return a list of top ten users (in '''/tmp/messagelist''') whose name is present in the 'To:' field of the messages stored. | ||
| Line 48: | Line 49: | ||
<nowiki>12 <DIV><B>To:</B> <A title=3Dsecretary@witalsee.com=20</nowiki> | <nowiki>12 <DIV><B>To:</B> <A title=3Dsecretary@witalsee.com=20</nowiki> | ||
<nowiki>7 <DIV><B>To:</B> <A title=3Drolucknow@witalsee.com=20</nowiki> | <nowiki>7 <DIV><B>To:</B> <A title=3Drolucknow@witalsee.com=20</nowiki> | ||
547 | 547 | ||
23 "KolkataRO Witalsee" <rokolkata@witalsee.com> | 23 "KolkataRO Witalsee" <rokolkata@witalsee.com> | ||
12 <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = | <nowiki>12 <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =</nowiki> | ||
11 "Pawan Kumar" <pawan.kumar@witalsee.com> | 11 "Pawan Kumar" <pawan.kumar@witalsee.com> | ||
11 KolkataRO Witalsee=20 | <nowiki>11 KolkataRO Witalsee=20</nowiki> | ||
11 <DIV><B>To:</B> <A title=3Drokolkata@witalsee.com=20 | <nowiki>11 <DIV><B>To:</B> <A title=3Drokolkata@witalsee.com=20</nowiki> | ||
From this we can guess that the folder '547', ie ''/opt/zimbra/store.old/0/547'', belongs to 'rokolkata@witalsee.com'. | From this we can guess that the folder '547', ie ''/opt/zimbra/store.old/0/547'', belongs to 'rokolkata@witalsee.com'. | ||
Latest revision as of 06:09, 26 July 2012
Zimbra Mailbox Structure[edit]
In Zimbra, each user is assigned a unique 'mailbox ID', which links him/her to their folder in /opt/zimbra/store/0.
Therefore a user with say mailbox ID '716', would have folder /opt/zimbra/store/0/716. The emails are stored in '.msg' format.
For more information on the structure, go here
The problem[edit]
Now this information is stored in LDAP, so if LDAP is corrupted or unrecoverable, we cannot associate the mailbox ID with the user ID.
But the store folder is intact.
The solution[edit]
We will have to trace which folder belongs to which user. Since each folder belongs to a single user, it is sufficient to determine with a few emails who the inbox belongs to.
So we follow these steps to recover it: In our case the backup store folder is /opt/zimbra/store.old/0
Go to the backup store folder:
# cd /opt/zimbra/store.old/0
Save the script as 'findusers.sh', and the run the script.
#!/bin/bash for line in `ls`; do echo $line >> /tmp/messagelist cat $PWD/$line/msg/0/* | grep To: | sed 's/To: //' | sort | uniq -c | sort -nr | head -5 >> /tmp/messagelist echo "" >> /tmp/messagelist done
# /opt/zimbra/store.old/0/findusers.sh
This will return a list of top ten users (in /tmp/messagelist) whose name is present in the 'To:' field of the messages stored. Using the output of this, we can make a good estimate of the user's folder, but this needs to be confirmed manually as well, by reading the email.
The output returned will be as follows:
546
37 "mis opns" <mis@witalsee.com>,
13 "dr brijesh singh rajawat" <brijeshsinghrajawat@witalsee.com>,
12 'Secretary'=20
12 <DIV><B>To:</B> <A title=3Dsecretary@witalsee.com=20
7 <DIV><B>To:</B> <A title=3Drolucknow@witalsee.com=20
547
23 "KolkataRO Witalsee" <rokolkata@witalsee.com>
12 <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
11 "Pawan Kumar" <pawan.kumar@witalsee.com>
11 KolkataRO Witalsee=20
11 <DIV><B>To:</B> <A title=3Drokolkata@witalsee.com=20
From this we can guess that the folder '547', ie /opt/zimbra/store.old/0/547, belongs to 'rokolkata@witalsee.com'.
But we need to confirm this by going to the folder /opt/zimbra/store.old/0/547, and reading a few sample emails to confirm that the directory belongs to 'rokolkata@witalsee.com'. Look for emails where there is only one recipient. This is a major clue. Also look for mails where there is one sender and and recipient of an outside domain. Since 'Sent' mails are also stored here, this would indicate that the email is sent by the user, to a remote recipient.
The mails can then be recovered by using zmmailbox as the Zimbra user.
Both the commands below give admin rights on zmmailbox prompt, so use any one.
zmmailbox -zadmin
or
zmmailbox adminAuthenticate -u https://server.domain.com:7071 admin@domain.com password
After that we create the 'Recovery' folder, and add messages to that folder from our old store folder.
mbox> selectMailbox agmadmin@witalsee.com mbox agmadmin@witalsee.com> createfolder /Recovery mbox agmadmin@witalsee.com> addMessage /Recovery /opt/zimbra/store.old/0/809/msg/0
/opt/zimbra/store.old/0/809/msg/0 is the path to the folder containing the mails. Some IDs may have a large amount of mails, resulting in msg/1, msg/2, etc. These will have to be run one-by-one.