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.

LUser
  • 217
  • 6
  • 15
  • You must be the `zimbra` user, did you try that? `sudo su zimbra` – Jacob Evans Jan 30 '18 at 04:57
  • Yes, Of course . I might have found out why this happens. – LUser Jan 30 '18 at 05: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 09:00
  • I have . I will post an answer in a couple seconds. – LUser Feb 13 '18 at 10:00
  • This seems to use the Zimbra account export function. There has been talk on the forum for a long time that those exports aren't actually importable. Ultimately, backing up the open source edition of Zimbra is difficult. I have a Zimbra server, and my safest bet is virtual machine snapshots. I know that I can't restore one e-mail from that, but so be it. I do also make a weekly account export just for the sake of it, but I don't know if that's useful. – Halfgaar Feb 01 '22 at 09:09

1 Answers1

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
LUser
  • 217
  • 6
  • 15