Results 1 to 10 of 11

Thread: [SOLVED] Using zmlmtpinject

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    52
    Rep Power
    10

    Default [SOLVED] Using zmlmtpinject

    I have the zimbra store directory containing the email messages as a backup. What is the best way to reinject the messages back into zimbra using zmlmtpinject? Is there documentation other than the command line help?

  2. #2
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    See Dan's post below.
    Last edited by KevinH; 11-16-2005 at 12:50 PM.

  3. #3
    Join Date
    Oct 2005
    Posts
    52
    Rep Power
    10

    Default

    So there is no way to re-inject the messages from the zimbra store directory back into zimbra?


    Quote Originally Posted by KevinH
    EDITED... See Dan's response below.
    Last edited by KevinH; 11-16-2005 at 12:54 PM.

  4. #4
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default zmlmtpinject *should* work

    Check out this thread for zmlmtpinject syntax.

    Your message store should be structured like this:
    Code:
    /opt/zimbra/store/{hash}/{mailbox-id}/msg/{hash}/{item}.msg
    In other words, all messages in an on-disk directory belong to the same user. So, once you've determined whose mailbox the messages correspond to, just use zmlmtpinject to inject them into the new Zimbra M2 server. You'll lose tags, contacts, folder structure, received dates, and read/unread status, but it should work.

    If you want to be extra-tricky, before you run zmlmtpinject you can write a perl script to add an extra "X-Zimbra-Received" header to each message, with the value being the same as the "Date:" header's value. Then zmlmtpinject will use that date as the "received date" when re-injecting the messages.

  5. #5
    Join Date
    Oct 2005
    Posts
    52
    Rep Power
    10

    Default

    Thank you. I followed your direction and wrote a little perl script to insert the X-Zimbra-Received header and zmlmtpinject worked.

    Can you share with us the hashing algorithm that zimbra uses so that it would make locating a user's mail directory much easier?

    Quote Originally Posted by dkarp
    Check out this thread for zmlmtpinject syntax.

    Your message store should be structured like this:
    Code:
    /opt/zimbra/store/{hash}/{mailbox-id}/msg/{hash}/{item}.msg
    In other words, all messages in an on-disk directory belong to the same user. So, once you've determined whose mailbox the messages correspond to, just use zmlmtpinject to inject them into the new Zimbra M2 server. You'll lose tags, contacts, folder structure, received dates, and read/unread status, but it should work.

    If you want to be extra-tricky, before you run zmlmtpinject you can write a perl script to add an extra "X-Zimbra-Received" header to each message, with the value being the same as the "Date:" header's value. Then zmlmtpinject will use that date as the "received date" when re-injecting the messages.
    Last edited by tron; 11-16-2005 at 05:10 PM.

  6. #6
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default You want the ID, not the hash.

    Quote Originally Posted by tron
    Can you share with us the hashing algorithm that zimbra uses so that it would make locating a user's mail directory much easier?
    Mailboxes are assigned increasing numeric IDs when they're created. The account ID -> mailbox ID mapping is in the ZIMBRA.MAILBOX table in the old install's database, which you may or may not any longer have access to. (There's a COMMENT field in that table that by default holds the email address of the mailbox owner.)

    The "hash" is just what you get by right-shifting the mailbox ID by N bits, so for your system all mailboxes will hash to 0.

  7. #7
    Join Date
    Dec 2006
    Posts
    23
    Rep Power
    9

    Default Thanks!

    This post REALLY saved my bacon. Thanks for the script.

  8. #8
    Join Date
    May 2006
    Location
    Costa Rica
    Posts
    5
    Rep Power
    9

    Default mailbox parse wrapper

    I usually back up my mysql when I do zimbra backups and I took the liberty of wrapping your script with this other snippet to auto parse all folders simultanously. Usually this works if I keep a full backup and only do incremental message store backups to sort out new messages. I full backup every week (turn off zimbra and tar the whole /opt/zimbra) and then rsync the message store periodically.

    asuming you are able to dump the mysql table with something like

    Code:
    mysql $> use zimbra;
    mysql $> select id,description from mailbox;
    and save that to list.txt (or something). I wrapped it up with this.

    Code:
    #!/bin/bash
    
    
    for x in `awk '{print "/opt/zimbra/store/0/"$1"/msg"}' /opt/list.txt`; do
            for i in `ls $x`; do
                    echo Zimdates::: sh /opt/zimdates.sh $x"/"$i;
                    sh /opt/zimdates.sh $x"/"$i;
            done;
    done;
    
    for k in `awk '{print $1":::"$2}' /opt/list.txt`; do
    
            echo "TEST::: /opt/zimbra/bin/zmlmtpinject `echo $k | awk '{ split($0, a, ":::"); print "-d /opt/zimbra/store/0/"a[1]"/msg -r "a[2]" -s "a[2]; exit}'`";
            /opt/zimbra/bin/zmlmtpinject `echo $k | awk '{ split($0, a, ":::"); print "-d /opt/zimbra/store/0/"a[1]"/msg/* -r "a[2]" -s "a[2]; exit}'`;
    done;

    just a thought.
    Last edited by RageLink; 12-03-2009 at 09:12 PM.

  9. #9
    Join Date
    Oct 2009
    Posts
    12
    Rep Power
    6

    Default

    Hi All,

    I came across the post as I'm in a similar situation. For me I fortunately had previous mysql dump unfortunately not too recent though. Currently I'm restoring back the Mysql dump and for the period of mails I don't have, which is like 2 week, I'm posting it back to the user from the store folder using the following command: zmmailbox -z -m user@mail.com addMessage /Inbox /Restore. This seems to keep the date of the messages. What I was wondering though if there is a way one could have zimbra re-map the store folders that are not recorded in the MySql db. Say for instance you have /opt/zimbra/0/11/msg/0 1 2 3 4 recorded in the db but not the additional sub folders that was created after the mysql dump e.g. 5 6 7.

    Just wondering

Similar Threads

  1. zmlmtpinject errors
    By wfweaver in forum Administrators
    Replies: 1
    Last Post: 06-29-2007, 10:38 AM
  2. About zmlmtpinject
    By chanck in forum Administrators
    Replies: 1
    Last Post: 03-20-2006, 09:17 AM
  3. zmlmtpinject sometimes hangs on errors
    By jigi in forum Administrators
    Replies: 6
    Last Post: 01-18-2006, 09:14 PM
  4. how can I use zmlmtpinject?
    By gmorchio in forum Installation
    Replies: 3
    Last Post: 11-16-2005, 10:18 AM
  5. zmlmtpinject not working
    By tron in forum Administrators
    Replies: 6
    Last Post: 10-15-2005, 05:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •