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 😀
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?
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 ~]#
***********************************************
Hi FA,
It’s your file tgz located in /srv/backup/110316? how much size file khietht@aajsc.com.vn.tgz?
Dear iman!
size file khietht@aajsc.com.vn.tgz located in /srv/backup/110316~ 50 MB
Hi FA,
Please try to import message via webmail. Go to Zimbra Webmail | Preferences | Export/Import. If process working fine, there something wrong with CLI 😀
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…
Hi,
Please try to make change permission with 777 and try again
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.
Hi, could you please give me a script for migrating user to my new zimbra server?
Please try this awesome tools : https://www.zextras.com/suite/migration-tool/
Hi,
I got same error too when tryin your script :
ERROR: service.FAILURE (system failure: POST failed, status=302 Moved Temporarily)
Any solution ?
Hello,
Please make sure mailbox services running well. You can see from zmcontrol status command
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.
Hi Beph,
Yes, it’s possible. You can rsync all /opt folder into new machine
Hello imam,
When I am trying to restore the mail box in zimbra 8.7 post migration I am getting following error :
finished
ERROR: service.FAILURE (system failure: POST failed, status=500 Server Error)
Hi Manav,
How about restore from webmail? You can login to webmail | Preferences | Export/Import
thanks for this documents i wnat to ask a question if i m importing a second time using this command does it skip or duplicate emails. thanks.
Hi Anis,
The data will be skip
Hai, can you help me.
*sorry my English bad (gatel mau pake bahasa tapi ga enak sama yang lain.
I use bulk restore mailbox from command but getting error with status 500, then I use script in this post the system asking about password.
this the command
for i in `cat /backups/zmigrate/emails.txt`; do zmmailbox -z -m $i postRestURL “/?fmt=tgz&resolve=skip” /backups/zmigrate/$i.tgz ; echo “$i — finished “; done
Hi mas Anas,
Please add -t 0 before postRestURL. So that like below :
kok saya email nya ga masuk ya?
Restore via cli in zimbra 8.8.12 have a problem, i was try with different options but always show error, now i’m trying restore via webmail and all run normally. I’m waiting tho finish the recovery process. Could someone run the recevery via cli?
Hello,
What the error message when you try the script?
ERROR: service.FAILURE (system failure: POST failed, status=500 500
This script working perfectly on my zimbra server.
“zmmailbox -z -m admin@example.com postRestURL ‘//?fmt=tgz&resolve=skip’ /srv/backup/20150128/admin@example.com.tgz”;
pake cara ini berhasil tapi ga masuk inbox nya knp ya mas?
Hi mas,
Bisa coba testing upload via webmail terlebih dahulu sukses atau tidak
Hi Pak Iman,
Nice article,
when I running backup restore all mailbox from your script, I get failed like below:
# sh restore-mailbox.sh
Restoring dwi@esign.id mailbox…
ERROR: zclient.CLIENT_ERROR (file not found: /home/infras/080124/dwi@esign.id.tgz) (cause: java.io.FileNotFoundException /home/infras/080124/dwi@esign.id.tgz (Permission denied))
Restoring edho@esign.id mailbox…
ERROR: zclient.CLIENT_ERROR (file not found: /home/infras/080124/edho@esign.id.tgz) (cause: java.io.FileNotFoundException /home/infras/080124/edho@esign.id.tgz (Permission denied))
my backup file on /home/infras/080124/ directory
I have try set chmode -R 777 on my backup folder, but still get the same error. My know, how to fix my case?
Thanks a lot Pak Iman.
Era
Hi Era,
Please try to put that file into /tmp/ folder. Then, please test again
Hi Pak Iman,
Great,
restoring mailbox running well since mailbox backup folder move to /tmp path.
Just I need to know, if mailbox backup folder located on /home/username, is it restricted and
not recommended?
or are there any optional way to make it working?
Thanks a lot for your help
Era
Hi Era,
Please try saving it in another folder such as in /srv as an example
Hi Iman,
Ok, I will try placed mailbox backup folder on another path directory beside of /home/username.
Thanks a lot for your help.
Era