zimbra mailbox 备份与恢复

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

view sourceprint?

1.vi /srv/backup-mailbox.sh

Fill with the following line

##!/bin/bash
clear

## Backup Format 
FORMAT=tgz

## Backup location
ZBACKUP=/srv/backup/

## Folder name for backup and using date
DATE=`date +"%d%m%y"`

## Backup location separate by date
ZDUMPDIR=$ZBACKUP/$DATE

## zmmailbox location
ZMBOX=/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 $ZDUMPDIR
fi

## Looping Account Zimbra
for account in `su - zimbra -c ‘zmprov -l gaa | sort‘`
do
echo "Processing mailbox $account backup..."
        $ZMBOX -z -m $account getRestURL "//?fmt=${FORMAT}$query" > $ZDUMPDIR/$account.${FORMAT}
done

echo "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

view sourceprint?

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 : 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 [email protected] postRestURL ‘//?fmt=tgz&resolve=skip‘ /srv/backup/20150128/[email protected]";

The above command will be restore backup mailboxes [email protected] user with reset resolver and the backup file is located in /srv/backup/20150128/[email protected]

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 

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

时间: 2024-10-21 07:51:44

zimbra mailbox 备份与恢复的相关文章

zimbra mailbox相关的命令

zmmailbox -z -m [email protected] mailbox: [email protected], size: 56.76 MB, messages: 544, unread: 3 authenticated as [email protected] mbox [email protected]> ls ERROR: zclient.CLIENT_ERROR (Unknown command: (ls) Type: 'help commands' for a list)

Zimbra 8.7.1GA更新

公司的zimbra 8.5.0用了差不多一年,看zimbra发布了新版本,直接升级8.7.1失败,于是先升级到8.6.0,希望能后续能直接升级到8.7.1,后来发现是绕不开的坑,必须把问题解决了才可以.于是在备份好系统快照的前提下,参考网络上的资料,开始了以下的升级.follow me--. 1.系统环境:    cat /etc/system-release     CentOS Linux release 7.3.1611 (Core)     uname -a     Linux mail

centos7 下安装zimbra all in one系统

Install Zimbra 8.7 on CentOS7 all in one server By   On July 26, 2016 In Zimbra Collaboration Tagged all in one zimbra, zimbra facebook tweet google+ We will look into installing Zimbra 8.7 on a single server.  All components like Zimbra LDAP, MTA ,

MySQL的备份与恢复具体解释

MySQL数据备份 在mySQL里面,有逻辑备份和物理备份.逻辑备份最大长处是对于各种存储引擎,都能够使用相同的方法来备份. 而物理备份则不同.不同的存储引擎有着不同的备份方法. 逻辑备份与恢复 备份 在MySQL中逻辑备份是使用mysqldump将数据库中的数据备份为一个文本文件,备份的文件能够被查看和编辑.依照备份范围,能够将备份分为下面三种备份. 备份指定的一个数据库或者该数据库中的某些表 mysqldump [options] 数据库名 [表名] > data.sql 备份指定的多个数据

zimbra 多租户管理员授权

In order to create a multi tenancy in zimbra OSA, can be acheived through a bash script below. Thanks to Ahmad Imanuddin (http://www.imanudin.com) for sharing this very useful script. cd /srv/ vi admin-delegate.sh Fill with the following line : #!/bi

MySQL备份与恢复

body { font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 1.6; padding-top: 10px; padding-bottom: 10px; background-color: white; padding: 30px } body>*:first-child { margin-top: 0 !important } body>*:last-child { margin-bottom:

42-2 mysql备份与恢复

02 mysql备份与恢复 实战:percona-xtrabackup备份还原数据库 原服务器:source 192.168.1.133 CentOS7.2  备份服务器:restore 192.168.1.132 CentOS7.2 1.使用indobackupex进行完全备份 [[email protected] ~]# yum install percona-xtrabackup-2.3.2-1.el7.x86_64.rpm [[email protected] ~]# rpm -ql p

How to change SMTP Banner, HELO,EHLO Greetings for Zimbra

1- Take Zimbra backup or VM snapshot before doing any changes 2- Enter the following command to change SMTP Banner: # su - zimbra $ zmlocalconfig -e postfix_smtpd_banner="yourmailserver.yourdomain.com" 3- Then if you want to change HELO/EHLO nam

web day16 数据库 完整性约束,mySQL编码问题,备份与恢复,多表查询

约束 * 约束是添加在列上的,用来约束列的! 1. 主键约束(唯一标识) ****非空*** ****唯一*** ****被引用**** * 当表的某一列被指定为主键后,该列就不能为空,不能有重复值出现. * 创建表时指定主键的两种方式: > CREATE TABLE stu( sid      CHAR(6) PRIMARY KEY, sname     VARCHAR(20), age         INT, gender     VARCHAR(10) ); 指定sid列为主键列,即为s