How To Restore Zimbra Mailbox

Home » Zimbra » How To Restore Zimbra Mailbox
Zimbra 19 Comments

After success backup mailbox as described from previous article on this section : Zimbra Tips : How To Backup Mailbox Daily, Weekly and Monthly, you could restore the backup mailboxes with zmmailbox command who has been provided by Zimbra. The example command is like below :

su - zimbra -c "zmmailbox -z -m username postRestURL '//?fmt=tgz&resolve=skip' folder/file-location.tgz";

Note :
resolve = skip. This parameters will keep mailboxes existing on users.

resolve = reset. This parameters will delete mailboxes existing on user and will be changed with mailbox backup. The reset parameter could be changed with skip, replace, modify.

folder/file-location.tgz is folder/file location backup mailboxes.

Example

su - zimbra -c "zmmailbox -z -m admin@example.com postRestURL '//?fmt=tgz&resolve=skip' /srv/backup/20150128/admin@example.com.tgz";

The above command will be restore backup mailboxes admin@example.com user with reset resolver and the backup file is located in /srv/backup/20150128/admin@example.com.tgz

For restore backup all user, you could make a script as below :

#!/bin/bash

BACKUPDIR="/srv/backup/20150128";

clear

echo "Retrieve all zimbra user name..."

USERS=`su - zimbra -c 'zmprov -l gaa | sort'`;

for ACCOUNT in $USERS; do
NAME=`echo $ACCOUNT`;
echo "Restoring $NAME mailbox..."
su - zimbra -c "zmmailbox -z -m $NAME postRestURL '//?fmt=tgz&resolve=skip' $BACKUPDIR/$NAME.tgz";
done
echo "All mailbox has been restored sucessfully"

Good luck and hopefully useful 😀

19 thoughts on - How To Restore Zimbra Mailbox

  • Failure while Restore Zimbra Mailbox
    ***********************************
    [root@mail ~]# sh /srv/restore-mailbox.sh
    Retrieve all zimbra user name…
    Restoring admin@aajsc.com.vn mailbox…
    ERROR: service.FAILURE (system failure: POST failed, status=302 Found)
    Restoring abc@aajsc.com.vn mailbox…
    ERROR: service.FAILURE (system failure: POST failed, status=302 Found)
    Restoring xyz@aajsc.com.vn mailbox…
    ERROR: service.FAILURE (system failure: POST failed, status=302 Found)
    .
    .
    .
    All mailbox has been restored sucessfully
    [root@mail ~]#
    ***********************************
    But i login mailbox -> No data??? Help me???

    • Hi FA,

      How about test with single command?

      su - zimbra -c "zmmailbox -z -m username postRestURL '//?fmt=tgz&resolve=reset' folder/file-location.tgz";
      
      • Dear iman!
        I tried to test with single command. I still the same issue…
        ***********************************************
        Type 1:

        [root@mail ~]# su – zimbra -c “zmmailbox -z -m admin@aajsc.com.vn postRestURL ‘//?fmt=tgz&resolve=reset’ /srv/backup/110316/admin@aajsc.com.vn.tgz”;
        ERROR: service.FAILURE (system failure: POST failed, status=302 Found)
        [root@mail ~]#
        ***********************************************
        Type 2:

        [root@mail ~]# /opt/zimbra/bin/zmmailbox -z -m khietht@aajsc.com.vn postRestURL “//?fmt=tgz&resolve=reset” /srv/backup/110316/khietht@aajsc.com.vn.tgz;
        ERROR: service.FAILURE (system failure: POST failed, status=302 Found)
        [root@mail ~]#
        ***********************************************

  • Dear iman!
    I try to import message via webmail. Go to Zimbra Webmail | Preferences | Export/Import => Browse -> khietht@aajsc.com.vn.tgz -> It’s OK
    And I also Export/Import a new file -> It’s OK
    Only run the commands (sh /srv/restore-mailbox.sh) or (su – zimbra -c “zmmailbox -z -m username postRestURL ‘//?fmt=tgz&resolve=reset’ folder/file-location.tgz”;) -> Not OK
    ****************************************
    How to fix? thanks you very much…

      • Dear iman!
        I tried to run the above command:
        (chmod 777 /srv/backup/110316/khietht@aajsc.com.vn.tgz)
        and try (chmod 777 /srv/backup/110316)
        and try (chmod 777 /srv/backup/)
        But still not be, the same result…
        => ERROR: service.FAILURE (system failure: POST failed, status=302 Found)

    • Hi,
      Please try to add -u options.

      su - zimbra -c "zmmailbox -z -m username -u https://ZIMBRAIP postRestURL '//?fmt=tgz&resolve=skip' folder/file-location.tgz";
      
  • Hi,

    I got same error too when tryin your script :
    ERROR: service.FAILURE (system failure: POST failed, status=302 Moved Temporarily)

    Any solution ?

      • Hi iman,

        All services looks running well :
        Host mail.xxxxxxxx.co.id
        amavis Running
        antispam Running
        antivirus Running
        dnscache Running
        ldap Running
        logger Running
        mailbox Running
        memcached Running
        mta Running
        opendkim Running
        proxy Running
        service webapp Running
        snmp Running
        spell Running
        stats Running
        zimbra webapp Running
        zimbraAdmin webapp Running
        zimlet webapp Running
        zmconfigd Running

    • para el error 302 en servidores 8.7 intenta las siguientes lineas

      zmprov md dominio.example.com zimbraPublicServiceProtocol https

      o

      zmprov md dominio.example.com zimbraPublicServiceProtocol both

      reinicias servicios
      zmcontrol restart

      e intentas hacer el import

      • Excelente realicé la migración de correos en un ministerio y no podía subir los respaldos, hice lo que indicas y funciona a la perfección, gracias totales!!!!!

  • iman,

    how can i transfer may user and mailbox settings on my new zimbra. need to transfer my zimbra server to a new computer i am using ubuntu 14.04 with zimbra 8.6 is it possible to copy all my user settings and mailbox thanks.

LEAVE A COMMENT