|
|
@ -7,7 +7,11 @@ mkdir -p /home/lbkp/zimbra/mount |
|
|
|
source /opt/zimbra/bin/zmshutil |
|
|
|
source /opt/zimbra/bin/zmshutil |
|
|
|
zmsetvars |
|
|
|
zmsetvars |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo 'Starting Zimbra backup' |
|
|
|
|
|
|
|
|
|
|
|
{% if 'ldap' in zcs_enabled_components %} |
|
|
|
{% if 'ldap' in zcs_enabled_components %} |
|
|
|
|
|
|
|
echo 'Dumping LDAP database' |
|
|
|
|
|
|
|
|
|
|
|
# Dump ldap data |
|
|
|
# Dump ldap data |
|
|
|
/opt/zimbra/common/sbin/slapcat \ |
|
|
|
/opt/zimbra/common/sbin/slapcat \ |
|
|
|
-F /opt/zimbra/data/ldap/config \ |
|
|
|
-F /opt/zimbra/data/ldap/config \ |
|
|
@ -19,6 +23,7 @@ zmsetvars |
|
|
|
{% if 'mailbox' in zcs_enabled_components %} |
|
|
|
{% if 'mailbox' in zcs_enabled_components %} |
|
|
|
|
|
|
|
|
|
|
|
# Dump MySQL data |
|
|
|
# Dump MySQL data |
|
|
|
|
|
|
|
echo 'Dumping MySQL database' |
|
|
|
/opt/zimbra/common/bin/mysqldump \ |
|
|
|
/opt/zimbra/common/bin/mysqldump \ |
|
|
|
--user=root \ |
|
|
|
--user=root \ |
|
|
|
--password=$mysql_root_password \ |
|
|
|
--password=$mysql_root_password \ |
|
|
@ -31,13 +36,20 @@ zmsetvars |
|
|
|
OLDIFS=$IFS |
|
|
|
OLDIFS=$IFS |
|
|
|
IFS=$'\n' |
|
|
|
IFS=$'\n' |
|
|
|
for MAILBOX in $(/usr/local/bin/zmprov getQuotaUsage $(hostname --fqdn) | awk '{ print $1}'); do |
|
|
|
for MAILBOX in $(/usr/local/bin/zmprov getQuotaUsage $(hostname --fqdn) | awk '{ print $1}'); do |
|
|
|
|
|
|
|
echo '' |
|
|
|
|
|
|
|
echo "Cheking contact and calendar folders for $MAILBOX" |
|
|
|
for LINE in $(/usr/local/bin/zmmailbox -z -m $MAILBOX -t 0 getAllFolders); do |
|
|
|
for LINE in $(/usr/local/bin/zmmailbox -z -m $MAILBOX -t 0 getAllFolders); do |
|
|
|
|
|
|
|
# Skip folders whose ID indicates it's a shared folder |
|
|
|
|
|
|
|
if echo $LINE | grep -qiP '^\s*[a-z0-9]{8}\-[a-z0-9]'; then |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
fi |
|
|
|
DIR=$(echo $LINE | perl -ne 'm/\s*\d+\s+(\w{4})\s+\d+\s+\d+\s+(\/.*)/ && print "$2\n"') |
|
|
|
DIR=$(echo $LINE | perl -ne 'm/\s*\d+\s+(\w{4})\s+\d+\s+\d+\s+(\/.*)/ && print "$2\n"') |
|
|
|
if echo $DIR | grep -qiP '\([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}:\d+\)$'; then |
|
|
|
if echo $DIR | grep -qiP '\([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}:\d+\)$'; then |
|
|
|
continue |
|
|
|
continue |
|
|
|
fi |
|
|
|
fi |
|
|
|
TYPE=$(echo $LINE | perl -ne 'm/\s*\d+\s+(\w{4})\s+\d+\s+\d+\s+(\/.*)/ && print "$1\n"') |
|
|
|
TYPE=$(echo $LINE | perl -ne 'm/\s*\d+\s+(\w{4})\s+\d+\s+\d+\s+(\/.*)/ && print "$1\n"') |
|
|
|
if [ "$TYPE" == "appo" -o "$TYPE" == "task" -o "$TYPE" == "cont" ]; then |
|
|
|
if [ "$TYPE" == "appo" -o "$TYPE" == "task" -o "$TYPE" == "cont" ]; then |
|
|
|
|
|
|
|
echo "Exporting folder $DIR (account $MAILBOX, type $TYPE)" |
|
|
|
mkdir -p /home/lbkp/zimbra/exports/$MAILBOX/$(dirname $DIR) |
|
|
|
mkdir -p /home/lbkp/zimbra/exports/$MAILBOX/$(dirname $DIR) |
|
|
|
fi |
|
|
|
fi |
|
|
|
if [ "$TYPE" == "appo" -o "$TYPE" == "task" ]; then |
|
|
|
if [ "$TYPE" == "appo" -o "$TYPE" == "task" ]; then |
|
|
@ -50,6 +62,7 @@ done |
|
|
|
IFS=$OLDIFS |
|
|
|
IFS=$OLDIFS |
|
|
|
|
|
|
|
|
|
|
|
{% endif %} |
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
|
|
# Try to snapshot Zimbra tree |
|
|
|
# Try to snapshot Zimbra tree |
|
|
|
systemd-cat /opt/zimbra/bin/zmbh --pre --snap-size=10G --verbose --mount=/home/lbkp/zimbra/mount --shutdown=ldap |
|
|
|
echo '' |
|
|
|
|
|
|
|
echo "Handle /opt/zimbra snapshot / bind mount on /home/lbkp/zimbra/mount" |
|
|
|
|
|
|
|
/opt/zimbra/bin/zmbh --pre --snap-size=10G --verbose --mount=/home/lbkp/zimbra/mount --shutdown=ldap |
|
|
|