Backup a user mailbox into multiple zips

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
cnvivek
Posts: 33
Joined: Sat Sep 13, 2014 3:13 am

Backup a user mailbox into multiple zips

Postby cnvivek » Fri Feb 10, 2017 1:21 pm

Hi All

I am in a peculiar issue, our mail server admin quit recently. Presently I am back to managing things. Now I found that he had not done any backup & cleaning process for BCC mailbox, it has grown to 92 GB. I am not able view any mail in the mail box, login to that mailbox taking long time and finally ends with request timed out. When I tried to delete old mail through command I am getting the below error

ERROR: remote.TIMEOUT (https://mail.mydomain.com:7071/service/admin/soap/) (cause: java.net.SocketTimeoutException Read timed out)

Now I plan to back up the whole mail box year vise and restore. Can anybody help me on this.


Regards
Vivek


User avatar
vavai
Advanced member
Advanced member
Posts: 159
Joined: Thu Nov 14, 2013 2:41 pm
Location: Indonesia
Contact:

Re: Backup a user mailbox into multiple zips

Postby vavai » Fri Feb 10, 2017 11:28 pm

Hi,

Below is a backup script for exporting mailbox based on range of date :

Code: Select all


##!/bin/bash
clear

## Backup Format
FORMAT=tgz

## Backup location
ZBACKUP=/srv/backup/

## Folder name for backup and using date
DATE=`date +"%d%m%y"`

## Backup location separate by date
ZDUMPDIR=$ZBACKUP/$DATE

## zmmailbox location
ZMBOX=/opt/zimbra/bin/zmmailbox

### Backup Option ###

## Based on few day ago until today, example 7 days ago

#HARI=`date --date='7 days ago' +"%m/%d/%Y"`
#query="&query=after:$HARI"

## Based on certain date , example 21 Jan 2017.

#query="&query=date:02/01/2017"

## Based from/to certain date. Example Backup Mailbox before 1 Dec 2016 and after 31 Oct 2016

query="&query=after:10/31/2016 before:12/01/2016"

if [ ! -d $ZDUMPDIR ]; then
        mkdir -p $ZDUMPDIR
fi

## Looping for Zimbra Account
for account in `su - zimbra -c 'zmprov -l gaa | sort'`
do
echo "Processing mailbox $account backup..."
        $ZMBOX -z -m $account -t 0 getRestURL "//?fmt=${FORMAT}$query" > $ZDUMPDIR/$account.${FORMAT}
done

echo "Zimbra Mailbox backup has been completed successfully."

cnvivek
Posts: 33
Joined: Sat Sep 13, 2014 3:13 am

Re: Backup a user mailbox into multiple zips

Postby cnvivek » Sat Feb 11, 2017 7:23 am

Hi Vavai

Thanks. I am getting same error, I suspect issue is due to time taken to access the 91 GB mailbox. So edited the session time out and trying

Regards
Vivek
Last edited by cnvivek on Sat Feb 11, 2017 7:42 am, edited 1 time in total.
User avatar
vavai
Advanced member
Advanced member
Posts: 159
Joined: Thu Nov 14, 2013 2:41 pm
Location: Indonesia
Contact:

Re: Backup a user mailbox into multiple zips

Postby vavai » Sat Feb 11, 2017 7:33 am

Hi,
cnvivek wrote:Hi Vavai

Thanks. I am getting same error, I suspect issue is due to time taken to access the 91 GB mailbox. Is there any way to change user session time out and will it help in this scenario.

Regards
Vivek


You can investigate the problem by looking at /opt/zimbra/log/mailbox.log and see whether any related info regarding the problem. AFAIK, user session timeout can be changed from Zimbra Admin | Manage | Account | edit apropriate account and see on "advance" tab or on Zimbra Admin | Configure | Class of Services | default | advanced.

According to error message, I think the error came from an error on mailbox services but you can try to change session timeout first to see will it helping your situation or not.
santhosh
Posts: 1
Joined: Sat May 04, 2019 12:20 pm

Re: Backup a user mailbox into multiple zips

Postby santhosh » Sat May 04, 2019 12:34 pm

Hello,

I used the below script to take the backup of email accounts for a specifics or as daily incremental backup. For specific dates, the emails are not getting into the backup .tar

ZHOME=/opt/zimbra
ZBACKUP=/mnt/mailbackup
ZCONFD=$ZHOME/conf
DATE=270419
ZDUMPDIR=$ZBACKUP/$DATE
ZMBOX=/opt/zimbra/bin/zmmailbox
TOB=`date`
query="&query=date:27/04/2019"
if [ ! -d $ZDUMPDIR ]; then
mkdir -p $ZDUMPDIR
#begin=`date +%s`
fi
echo " Running zmprov ... "
for mbox in `su - zimbra -c 'zmprov -l gaa | sort'`
do
echo " Generating files from backup $mbox ..."
$ZMBOX -z -m $mbox getRestURL "//?fmt=tgz$query" > $ZDUMPDIR/$mbox.zip
done
if [ "$?" -ne "0" ]; then
STATUS='FAILED'
else
STATUS='SUCCEEDED'
fi
#end=`date +%s`
#secs=$((end-begin))
#hours=`printf '%dh:%dm:%ds\n' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))`
DETAILS=`cat /mnt/mailbackup/backupdetails.txt`
size=$(du -sh $ZDUMPDIR | awk {'print $1'})


the error which I'm getting is

ERROR: service.FAILURE (system failure: GET from https://mail.domain.in:443/home/user1@d ... 27/04/2019 failed, status=500. Server Error)
Generating files from backup user1@domain.in ...
ERROR: service.FAILURE (system failure: GET from https://mail.domain.in:443/home/user2@d ... 27/04/2019 failed, status=500. Server Error)


can you suggest......
qadir52786
Posts: 41
Joined: Sat Sep 13, 2014 3:58 am

Re: Backup a user mailbox into multiple zips

Postby qadir52786 » Fri Mar 05, 2021 2:44 pm

Sir can you provice me the restore script also
Thanks in Advance


vavai wrote:Hi,

Below is a backup script for exporting mailbox based on range of date :

Code: Select all


##!/bin/bash
clear

## Backup Format
FORMAT=tgz

## Backup location
ZBACKUP=/srv/backup/

## Folder name for backup and using date
DATE=`date +"%d%m%y"`

## Backup location separate by date
ZDUMPDIR=$ZBACKUP/$DATE

## zmmailbox location
ZMBOX=/opt/zimbra/bin/zmmailbox

### Backup Option ###

## Based on few day ago until today, example 7 days ago

#HARI=`date --date='7 days ago' +"%m/%d/%Y"`
#query="&query=after:$HARI"

## Based on certain date , example 21 Jan 2017.

#query="&query=date:02/01/2017"

## Based from/to certain date. Example Backup Mailbox before 1 Dec 2016 and after 31 Oct 2016

query="&query=after:10/31/2016 before:12/01/2016"

if [ ! -d $ZDUMPDIR ]; then
        mkdir -p $ZDUMPDIR
fi

## Looping for Zimbra Account
for account in `su - zimbra -c 'zmprov -l gaa | sort'`
do
echo "Processing mailbox $account backup..."
        $ZMBOX -z -m $account -t 0 getRestURL "//?fmt=${FORMAT}$query" > $ZDUMPDIR/$account.${FORMAT}
done

echo "Zimbra Mailbox backup has been completed successfully."


Return to “Administrators”

Who is online

Users browsing this forum: No registered users and 13 guests