backup zimbra differential?

Ask questions about your setup or get help installing ZCS server (ZD section below).
Post Reply
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

backup zimbra differential?

Post by killmasta93 »

Hi,

I was wondering if someone has found a script to backup differential currently im using this script but it does full backup which is a hassle because i have mailboxes of 10-15 gigs which takes a long time


Thank you

Code: Select all

#!/bin/bash

DOMAIN=''
DESTINATION=/opt/zimbra/backup/mailbox
DESTINATION_PREFIX=zmbrbckp
KEEP=5

function help
	{	
		echo "
		USAGE
		-d, --domain WORD			backup accounts with the specified WORD in the name, insert u/domain.ltd for filtering by domain
		-f, --folder /PATH/TO/DIRECTORY		backup to specified path, default /opt/zimbra/backup/mailbox can be modified in the script file
                -k, --keep X                            keep X previous backups, by default 5. The older backups will be automatically deleted. Has to be integer, the default number can be modified in the script file.
                -h, --help                              display this help

                "
		}  


while [[ $# -ge 1 ]]
do
key="$1"

case $key in
    -d|--domain)
	if [ -z $2 ]; then echo "domain option selected, but no domain inserted"
	exit 1
	fi
    DOMAIN="$2"
    shift # past argument
    ;;
    -f|--folder)
        if [ -z $2 ]; then 
		echo "folder option selected, but no path specified"
        	exit 1
        fi
	
	if ! [ -d "$2" ]; then
		echo "the specified path is not valid"
		exit 1
	fi

    DESTINATION="$2"
    shift # past argument
    ;;
    -k|--keep)
	case $2 in
    		''|*[!0-9]*) 
			echo "the specified keep argument is not an integer"
			exit 1
			;;
		*) KEEP=$2 ;;
	esac
    shift # past argument
    ;;
    -h|--help)
	help
	exit 1
    shift #past argument
    ;;
    *)
	echo "unknown option"
	help
	exit 1
            # unknown option
    ;;
esac
shift # past argument or value
done

#set the real destination path, with selected path, prefix and today date
DESTINATION_FINAL=$DESTINATION/$DESTINATION_PREFIX-$(date '+%Y-%m-%d')

#keep only 5 folders with backups
cd $DESTINATION
rm -rf $(ls -1dt $DESTINATION/$DESTINATION_PREFIX-* | tail -n +$KEEP)

#create the folder for the today backup
mkdir $DESTINATION_FINAL


echo ----
echo "selected domain " $DOMAIN
echo "selected keeping number " $KEEP
echo "selected destination folder " $DESTINATION
echo "the final destination folder is: " $DESTINATION_FINAL
echo ----

#here we test if domain variable is set and then chose accounts to backup
if [ -z $DOMAIN ]; then
	ACCOUNTS=$(/opt/zimbra/bin/zmprov -l gaa)
else
	ACCOUNTS=$(/opt/zimbra/bin/zmprov -l gaa | grep $DOMAIN)
fi

for account in $ACCOUNTS; 
		do
			echo "starting backup for" $account
			/opt/zimbra/bin/zmmailbox -z -m $account -t 0 getRestURL '//?fmt=tgz' > $DESTINATION_FINAL/$account.tgz
			echo "finished backup for " $account
       		done
User avatar
fs.schmidt
Outstanding Member
Outstanding Member
Posts: 278
Joined: Sat Sep 13, 2014 3:37 am
Location: Brazil
Contact:

Re: backup zimbra differential?

Post by fs.schmidt »

Hi,

Please take a look at this documentation:

https://wiki.zimbra.com/wiki/Ajcody-Migration-Notes

Search for "Export Using Query String - Before And After Dates"

Best regards.
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: backup zimbra differential?

Post by killmasta93 »

Thanks for the reply, not thats an automatic way to do backups? was looking at zmbackup but its weird how it does the backup
User avatar
fs.schmidt
Outstanding Member
Outstanding Member
Posts: 278
Joined: Sat Sep 13, 2014 3:37 am
Location: Brazil
Contact:

Re: backup zimbra differential?

Post by fs.schmidt »

killmasta93 wrote:Thanks for the reply, not thats an automatic way to do backups? was looking at zmbackup but its weird how it does the backup
Hi,

The best way to implement a backup supported by zimbra with real time is the Zimbra NG Backup module:

https://wiki.zimbra.com/wiki/Zimbra_NG_ ... p_NG_Works

You can hire only this feature with Zimbra Suite Plus.

Best regards.
Best regards.
Fabio S. Schmidt
http://www.bktech.com.br
Brasília - Brazil
Post Reply