uenderson/Zimbra — Issue #1: Backup Zimbra
Author: uenderson
Created: 2011-10-17 18:51:02+00:00
State: open

#!/bin/bash
# Program: Backup and Restore Zimbra
# written by uenderson ferrari
#
# This program implements the policy of secure password and login policy.
# Force the user to change the password in a certain period and ensures
# greater safety in consecutive unsuccessful login attempts.
#
#
# Description:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# DESCRIPTION PROCESS
# -----------------------
# SCRIPT DE BACKUP ZIMBRA
# -----------------------
#
# DATA: 20090606
# _______________________________________________________________
#
# O SCRIPT CRIA UMA PASTA DENOMINADA "BACKUP" NA RAIZ "/".
# PARA CADA BACKUP ELE CRIA UMA PASTA DENTRO DA PASTA BACK-
# UP COM O NOME NO FORMATO YYYYMMAA.
#
# É EFETUADO UM BACKUP INDIVIDUAL E AO FINAL UM BACKUP GERAL
# COMPACTADO COM BZIP2. AO FINAL, OS ARQUIVOS INDIVIDUAIS SÃO
# EXCLUÍDOS PARA ECONOMIA DE ESPAÇO FICANDO DENTRO DE CADA
# PASTA UM UNICO ARQUIVO "*TAR.BZ2" E UM ARQUIVO CONTENDO A
# LISTA DE USUARIOS QUE EXISTEM DENTRO DO ARQUIVO COMPACTADO.
# ESTE ARQUIVO SERVIRÁ PARA CONSULTA NA EXECUÇÃO DO RESTORE.
#
#
# _______________________________________________________________

clear
DATA=`date +%Y%m%d`
ZHOME="/opt/zimbra"
ZBACKUP="/backup/"
ZMBOX="$ZHOME/bin/zmmailbox"
STMP="$ZBACKUP/lista"

if [ ! -d $ZBACKUP ]; then
mkdir -p $ZBACKUP
fi

if [ ! -d $ZBACKUP$DATA ]; then
mkdir -p $ZBACKUP$DATA
fi

echo
echo
# #######################"
# #### Backup Zimbra ####"
# #######################"
echo
# ==> Starting backup... "
/opt/zimbra/bin/zmprov -l gaa > $STMP
cat $STMP | sort -o $STMP
for mbox in `cat $STMP`
do
echo -n " *"
sleep 1
echo -n " Compressing account the $mbox:" ; # ==> ok"
$ZMBOX -z -m $mbox getRestURL "/?fmt=tgz" > $ZBACKUP/$DATA/$DATA-$mbox.tar.gz
done
echo
# Generating report the backup... "
ls -lah $ZBACKUP/ | grep $DATA > $ZBACKUP$DATA/$DATA-relatorio
cp -a $ZBACKUP/lista $ZBACKUP/$DATA/1-lista