Zimbra Backup and Restore Script

Zimbra Backup and Restore

BACKUP
Script 1 Bu betik root olarak çalıştırılması gerekir, bu komut runBackupAll.sh çalışır ve aynı zamanda ikinci bir makineye tüm yedekleme gönderir.

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/zmmailboxif
[ ! -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 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

Kaynak : http://wiki.zimbra.com/wiki/Backing_up_and_restoring_Zimbra_%28Open_Source_Version%29#Another_option

http://sourceforge.net/projects/zimbra/files/

 

Zimbra Backup and Restore Script

admin

Bütün Hayatım Linux Sistemleri...

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir