venerdì 26 agosto 2011

Zimbra - HowTo backup zimbra free edition FOSS

Backup of Zimbra free edition FOSS
is based on the command
#zmmailbox -z -m account@domain getRestURL '//?fmt=tgz' > /where/doyouwant/backup.tgz
that export all account content
Set the user in Maintenance mode,
When a mailbox status is set to maintenance, login is disabled,and mail addressed to the account is queued at the MTA.
An account can be set to maintenance mode for backing up, importing or restoring the mailbox.
#zmprov ma account@domain.com zimbraAccountStatus maintenance
Restore user in Active State
#zmprov ma account@domain.com zimbraAccountStatus active
[zimbra@zimbra]$ cat esporta_account.sh
#!/bin/bash


DIR='/opt/zimbra/backup';


LOG=$DIR/backup.log
USERS_LIST=`/opt/zimbra/bin/zmprov -l getAllAccounts`;
DATE=`date +%Y-%m-%d`;


echo ""> $LOG
echo "#############################" >> $LOG
echo "#######-START BACKUP-#######" >> $LOG
echo "#######-$DATE-##########"  >> $LOG
echo "">> $LOG


for ACCOUNT in $USERS_LIST
do
 echo SettingUp Maintenance mode for account: $ACCOUNT >> $LOG
 /opt/zimbra/bin/zmprov ma $ACCOUNT zimbraAccountStatus maintenance
 echo Backup of account: $ACCOUNT >> $LOG
 echo Dimension of account : $ACCOUNT `/opt/zimbra/bin/zmmailbox -z -m $ACCOUNT gms` >> $LOG
 /opt/zimbra/bin/zmmailbox -z -m $ACCOUNT getRestURL '//?fmt=tgz' > $DIR/$DATE-$ACCOUNT.tgz;
 if [ $? == 0 ]
    then echo Backup account: $ACOUNT OK >> $LOG
    else echo Backup account: $ACOUNT ERROR >> $LOG
 fi
 echo Restoring Active mode for account: $ACCOUNT >> $LOG
 /opt/zimbra/bin/zmprov ma $ACCOUNT zimbraAccountStatus active
 echo "">> $LOG
done


echo "#######-END   BACKUP-#######" >> $LOG
echo "#######-$DATE-##########"  >> $LOG
echo "#############################" >> $LOG
echo "" >> $LOG


# SEND MAIL REPORT
cat $LOG | mail -s 'Backup Zimbra FOSS' backup_control@domain
[zimbra@zimbra]$


Restore from Backup 

#Create an parallel account where put the restored data
zmprov ca account_restore@domain pwd


# Restore on the parallel account (you must have the file of the backup!!)
zmmailbox -z -m account_restore@domain postRestURL "//?fmt=tgz&resolve=reset" /where/doyouwant/backup.tgz


But.... that's all?????

3 commenti:

beable@beable.it ha detto...

Ciao ... interessante script di backup.

su che versione della FOSS l'hai provato ??

A me produce l'errore "ERROR: service.AUTH_EXPIRED (auth credentials have expired)".
Dovrebbe essere causato da un bug esistente in tutte le versione di ZCS (bug 33170)

Ciao

Unknown ha detto...

Prova a vedere se questo ti può risolvere il problema.

http://www.zimbra.com/forums/administrators/27580-error-service-auth_expired-auth-credentials-have-expired.html

Lo script lo uso in 7.1.x

diablo666 ha detto...

Ciao Dario,
in effetti anche io ho lo stesso problema sull' AUTH.EXPIRED.

Ho provato a fare come suggerito nel thread che hai linkato ma non funziona ugualmente.

Leggevo però che è un problema dovuto al fatto che l'email viene messa in matinenece mode.

http://www.zimbra.com/forums/administrators/35492-error-service-auth_expired-auth-credentials-have-expired.html

Qualche idea?

Posta un commento