0

Good day everyone

So I am trying to perform a backup on out zimbra server and I found documentation (Zimbra Backup Proceedures ) and realised that the scripts aren't working correctly.

Scripts from documentation

runBackupAll.sh :

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 (10.0.0.X - CrossOver Cable on eth1 \o/ ) ..."
rsync -avH $ZBACKUP root@ipaddress:/opt/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"

Second Script:

* 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

This script fails on this section.

    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

The following command returns ...

zmmailbox -z -m bob@mail.somehost.com -t 0 getRestURL "/inbox?fm ERROR: zclient.IO_ERROR (Unable to get REST resource from https://FQDN/home/bob@mail.somehost.com/inbox?fmt=zip: FQDN) (cause: java.net.UnknownHostException FQDN)

I noticed I can download my emails for myself when I am logged in through the web interface. https://mail.somedomain.com/home/bob///?fmt=tgz .

I need though to be able to access them all and obviously without logging into each and every account.

How can I backup everyone's emails? From what I understand, the script fails because it wants a FQDN but I cannot set this parameter or at least from what I've tried , has yielded no results.

  • You must be the zimbra user, did you try that? sudo su zimbra – Jacob Evans Jan 30 '18 at 4:57
  • Yes, Of course . I might have found out why this happens. – Qndel Jan 30 '18 at 5:58
  • Hi @ApertureSecurity if you have found the solution, please enlighten us. If not, it looks like a configuration error in Zimbra. Please check the public service hostname on the domain you're trying to backup. – Micha Kersloot Feb 13 '18 at 9:00
  • I have . I will post an answer in a couple seconds. – Qndel Feb 13 '18 at 10:00
0

so there is a way to specify the hostname in the script. I made this and feel free to copy and use as you see fit. Run this as the zimbra user.

#!/bin/bash

#check that only the Zimbra user runs this.
if [ "$(whoami)" != "zimbra" ]; then
        echo "Script must be run as user: zimbra"
        exit -1
fi

echo " Running zmprov ... "

for mbox in `zmprov -l gaa`
do
echo " Generating files from backup $mbox ..."

zmmailbox -z -m $mbox  getRestURL -u "https://example.com" "//?fmt=zip" > "/opt/zimbra/backup/dump/backup_${mbox}.zip"

done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.