Zimbra briefcase export tool

Simple shell script to retrieve all user accounts from Zimbra, and recursively download Briefcase contents into user-named subfolders.

Script requires https url of zimbra server with active admin account/password.

#!/bin/bash
#
# Zimbra Briefcases export tool by LouiSe@louise.hu
#
# Usage (run on Zimbra server):
#  ./zimbra-briefcase-export.sh "https://myzimbra.com:7071" "admin@myzimbra.com" "mypassword"
#

ZIMBRA_HOST=$1
ACCOUNT_LIST=/tmp/zimbra_accounts.txt
ACCOUNT_ADMIN=$2
ACCOUNT_PASSWORD=$3
OUTPUT_DIR=briefcases
BRIEFCASE_DIR=Briefcase
PACKAGE_EXTENSION=tgz

mkdir ${OUTPUT_DIR}

echo "Retrieving all accounts from Zimbra into file '${ACCOUNT_LIST}'..."
su - -c "zmprov -l gaa >${ACCOUNT_LIST}" zimbra

echo "Processing all accounts on Zimbra host '${ZIMBRA_HOST}'"
while read USERNAME
do
    echo "Downloading Briefcase for account '${USERNAME}' into file '${USERNAME}.zip' and uncompressing..."
    curl -k --user "${ACCOUNT_ADMIN}:${ACCOUNT_PASSWORD}" "${ZIMBRA_HOST}/home/${USERNAME}/Briefcase?fmt=${PACKAGE_EXTENSION}" -o ${OUTPUT_DIR}/${USERNAME}.${PACKAGE_EXTENSION}
    cd ${OUTPUT_DIR}
    tar xzf ${USERNAME}.${PACKAGE_EXTENSION}
    mv ${BRIEFCASE_DIR} ${USERNAME}
    rm ${USERNAME}.${PACKAGE_EXTENSION}
    cd ..
done < ${ACCOUNT_LIST}
echo "Done."

Just like a Zimbra to Alfresco (User Homes) document library migration tool...

One thought on “Zimbra briefcase export tool”

  1. LouiSe,

    As per my understanding this a script to import in a zimbra server the briefcase from another zimbra server (i.e. to move zimbra to a new server). Should I run this script from root or zimbra user?.

Leave a Reply

Your email address will not be published. Required fields are marked *