Zimbra Hot Backup Restore Tool

Tool to create and restore backups of Zimbra open source.
Zimbra Backup and Restore "hot". By Richardson Limahttp://br.linkedin.com/in/richardsonlima
Developed in Bash Script, but currently under development in the Python programming language.

BACKUP

Script 1 This script must be run as root, it runs the script runBackupAll.sh and also sends the entire backup to a second machine.
``` echo "***************************************************" echo "* Zimbra - Backup all email accounts *" echo "***************************************************" echo"" # echo Start time of the backup = $(date +%T)
before="$(date +%s)" # echo "" ZHOME=/opt/zimbra ZBACKUP=$ZHOME/backup/mailbox echo "Generating backup files ..." su - zimbra -c "/opt/backup/SCRIPT_ZIBRA_BACKUP_ALL_ACCOUNTS/zimbra_backup_allaccounts.sh" echo "Sending files to backup all email accounts for Machine2 ..." rsync -avH $ZBACKUP root@ipaddress:/backup/zimbra_backup_accounts before2="$(date +%s)" # echo The process lasted = $(date +%T)

Calculating time

after="$(date +%s)" elapsed="$(expr $after - $before)" hours=$(($elapsed / 3600)) elapsed=$(($elapsed - $hours * 3600)) minutes=$(($elapsed / 60)) seconds=$(($elapsed - $minutes * 60)) echo The complete backup lasted : "$hours hours $minutes minutes $seconds seconds" ```
Script 2 zimbraBackupAllAccounts.sh
ZHOME=/opt/zimbra ZBACKUP=$ZHOME/backup/mailbox ZCONFD=$ZHOME/conf DATE=`date +"%a"` ZDUMPDIR=$ZBACKUP/$DATE ZMBOX=/opt/zimbra/bin/zmmailbox if [ ! -d $ZDUMPDIR ]; then mkdir -p $ZDUMPDIR fi echo " Running zmprov ... " for mbox in `zmprov -l gaa` do echo " Generating files from backup $mbox ..." $ZMBOX -z -m $mbox getRestURL "//?fmt=zip" > $ZDUMPDIR/$mbox.zip done

RESTORE

Script 3 This script must be run as root, it runs the script runRestoreAll.sh and also sends the entire backup to machine. zimbra_restore_allaccounts.sh
``` echo "***************************************************" echo "* Zimbra - Restore all email accounts *" echo "***************************************************" echo "" # echo Start Time Restore = $(date +%T)
before="$(date +%s)" # echo "" echo "Starting the process restore the backup files ..." su - zimbra -c "/opt/zimbra_backup_accounts/zimbra_restore_allaccounts.sh" before2="$(date +%s)" echo The process lasted = $(date +%T)

Calculating time

after="$(date +%s)" elapsed="$(expr $after - $before)" hours=$(($elapsed / 3600)) elapsed=$(($elapsed - $hours * 3600)) minutes=$(($elapsed / 60)) seconds=$(($elapsed - $minutes * 60)) echo "The complete restore lasted : "$hours hours $minutes minutes $seconds seconds" echo "Process completed successfully!" ```
**Script 4 zimbra_restore_allaccounts.sh ```

!/bin/bash

ZHOME=/opt/zimbra

!/bin/bash

ZHOME=/opt/zimbra

ZBACKUP=$ZHOME/backup/mailbox

ZBACKUP=/opt/zimbra_backup_accounts/mailbox ZCONFD=$ZHOME/conf DATE=date +"%a"ZDUMPDIR=$ZBACKUP/$DATE ZMBOX=/opt/zimbra/bin/zmmailbox if [ ! -d $ZDUMPDIR ]; then echo "Backups do not exist !" exit 255; fi for mbox in zmprov -l gaa do echo " Restoring files from backup $mbox ..." $ZMBOX -z -m $mbox postRestURL "//?fmt=zip&resolve=reset" $ZDUMPDIR/$mbox.zip done ```**


EmoticonEmoticon