博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zimbra mailbox 备份与恢复
阅读量:6982 次
发布时间:2019-06-27

本文共 3459 字,大约阅读时间需要 11 分钟。

How To Backup Mailbox Daily, Weekly and Monthly

For backup mailbox, i am usually using zmmailbox command who has been provided by Zimbra. The command usually will backup all mailbox on the users. But in this case, i want to backup mailbox daily, weekly, monthly or by certain time/date. For to do that, i could using the simple script and execute every night by crontab.

# Make file backup-mailbox.sh in /srv directory

1.vi /srv/backup-mailbox.sh

Fill with the following line

##!/bin/bashclear## Backup Format FORMAT=tgz## Backup locationZBACKUP=/srv/backup/## Folder name for backup and using dateDATE=`date +"%d%m%y"`## Backup location separate by dateZDUMPDIR=$ZBACKUP/$DATE## zmmailbox locationZMBOX=/opt/zimbra/bin/zmmailbox### Backup Option ##### Based on few day ago until today, example 7 days ago#HARI=`date --date='7 days ago' +"%m/%d/%Y"`#query="&query=after:$HARI"## Based on certain date , example 21 Jan 2015.#query="&query=date:01/21/2015"## Based from/to certain date. Example Backup Mailbox before 21 Jan 2015 and after 10 Jan 2015#query="&query=after:01/10/2015 before:01/21/2015"if [ ! -d $ZDUMPDIR ]; then        mkdir -p $ZDUMPDIRfi## Looping Account Zimbrafor account in `su - zimbra -c 'zmprov -l gaa | sort'`doecho "Processing mailbox $account backup..."        $ZMBOX -z -m $account getRestURL "//?fmt=${FORMAT}$query" > $ZDUMPDIR/$account.${FORMAT}doneecho "Zimbra Mailbox backup has been completed successfully."

Note : The above script has 3 method backup. First backup by few days ago. Second backup by certain date and third backup based on from/to certain date. Don’t forget to remove # 1 of 3 method what do you want. Save the script and give execution access

1.chmod +x /srv/backup-mailbox.sh

2.sh /srv/backup-mailbox.sh

If you want to execute every night, you can place the script in the crontab for automatically execute

Good luck and hopefully useful 

How To Restore Zimbra Mailbox

After success backup mailbox as described from previous article on this section : , 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/bashBACKUPDIR="/srv/backup/20150128";clearecho "Retrieve all zimbra user name..."USERS=`su - zimbra -c 'zmprov -l gaa | sort'`;for ACCOUNT in $USERS; doNAME=`echo $ACCOUNT`;echo "Restoring $NAME mailbox..."su - zimbra -c "zmmailbox -z -m $NAME postRestURL '//?fmt=tgz&resolve=skip' $BACKUPDIR/$NAME.tgz";doneecho "All mailbox has been restored sucessfully"

Good luck and hopefully useful 

https://www.zextras.com/suite/migration-tool/

      本文转自Tenderrain 51CTO博客,原文链接:http://blog.51cto.com/tenderrain/1931079,如需转载请自行联系原作者

你可能感兴趣的文章
盒马鲜生颠覆传统生鲜市场的胜算几何?
查看>>
“无人化时代”正在逼近,网友:再不努力就无工可打啦!
查看>>
【Node】常用基础 API 整理
查看>>
传神成进博会唯一指定智能翻译硬件提供商 力助无障碍沟通
查看>>
微信小程序实现slideUp、slideDown滑动效果及点击空白隐藏功能示例
查看>>
Java程序员须知:分布式微服务为什么很难?
查看>>
SQLServer之创建唯一聚集索引
查看>>
好程序员web前端技术之CSS3过渡
查看>>
java B2B2C源码电子商务平台 - Zuul回退机制
查看>>
记录Docker in Docker 安装(CentOS7)
查看>>
简单的写一个发布订阅器
查看>>
重学前端-js的类型问题
查看>>
Function类型
查看>>
Python学习
查看>>
你有多渴望赚钱
查看>>
ES6之let和const
查看>>
关于跨域
查看>>
一个半路出家的前端工程师的2018 | 掘金年度征文
查看>>
Fork/Join 框架介绍
查看>>
topK问题
查看>>