Zimbra Granular Mailboxes Backup and Automatic Restore with Bacula and bpipe Plugin

The Zimbra server must have the Bacula client installed and configured, and the following script must be on the same machine. The script lists all Zimbra email boxes (zmprov -l gaa) and backs up each of them directly to Bacula through the bpipe plugin.

The process is automatic when restoring the mailbox. Messages, calendar events, and all other user items are automatically restored to Zimbra. Existing similar items are not overwritten (skip).

The automatic restore requires some disk space on the Zimbra server because of a postRestURL command limitation that does not allow data to be read directly from the FIFO.

#!/bin/bash
#
# /opt/bacula/etc/bpipe_zimbra.sh
#
# Script to generate Bacula FileSet bpipe syntax configuration in order to backup all Zimbra mailboxes. 
#
# Autorhip: Heitor Faria (Copyleft: all rights reversed).
# Tested by: xxxx
# 
# It must be called at the FileSet INCLUDE Sub-resource used by the job that backups Zimbra like this (e.g.):
#
#    Plugin = "\|/opt/bacula/etc/bpipe_zimbra.sh"
#

zimbra_command="/opt/zimbra/bin/zmmailbox -z -m" 

for zimbra_user in $(/opt/zimbra/bin/zmprov -l gaa); do
  echo "bpipe:/var/$zimbra_user.tar:$zimbra_command $zimbra_user -t 0 getRestURL '/?fmt=tar':dd of=/tmp/$zimbra_user.tar && $zimbra_command $zimbra_user -t 0 postRestURL -i '//?fmt=tar&resolve=skip' /tmp/$zimbra_user.tar"
done

Screenshots

Zimbra Granular Mailboxes Backup and Automatic Restore with Bacula and bpipe Plugin 1 Zimbra Granular Mailboxes Backup and Automatic Restore with Bacula and bpipe Plugin 2

Disponível em: pt-brPortuguês (Portuguese (Brazil)) enEnglish esEspañol (Spanish)

Leave a Reply

Close Menu