Subversion Repositories oZimbraBackup

Compare Revisions

Regard whitespace Rev 4 → Rev 5

/branches/1.0.x/changelog.txt
1,3 → 1,10
2016-04-01 Marcus Uddenhed <marcus@osource.se>
 
* oZimbraBackup.sh (core): Fixed backup problem with LDAP database, using built in mdb_copy to not copy db file in sparse mode.
See following link for more info: https://wiki.zimbra.com/wiki/OpenLDAP_Performance_Tuning_8.0#mdb_copy_utility
* oZimbraBackup.sh (core): Removed some obsolete code.
 
2015-12-14 Marcus Uddenhed <marcus@osource.se>
 
* oZimbraBackup.sh (core): Modified path to zmcontrol for startup and shutdown.
/branches/1.0.x/oZimbraBackup.sh
24,7 → 24,7
# Developer: oSource Development(as of 2009-07-01)
# DevTeam: Marcus Uddenhed
# Version: 1.0.7
# Updated: 2015-12-14 22:17
# Updated: 2016-04-01 15:30
#
 
#### Global Settings ####
36,7 → 36,7
ZimLogEnable=yes # Turns logging on or off(yes/no).
ZimLogLogRotate=no # Enables log rotating(yes/no)
ZimLogRotateInt=day # How often should we rotate logs(day, week or month)
ZimLogPath=/opt/logs # Folder for log files
ZimLogPath=/opt/backup/logs # Folder for log files
ZimLogVerbose=no # Activates extra logging information(yes/no)
 
#### File Transfer Settings ####
147,12 → 147,19
}
 
full_backup() {
# Cleaning LDAP database from backup folder if exist.
if [ -f "$ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db/data.mdb" ];
then
rm $ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db/data.mdb
fi
 
# Making backup
if [ $ZimLogEnable = 'yes' ] && [ $ZimLogVerbose = 'yes' ]
then
 
# Hot sync before shutdown on zimbra folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder..." >> $ZimLogFile
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
rsync -avHK --delete --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder done." >> $ZimLogFile
 
# Stopping Zimbra
160,7 → 167,9
 
# Cold sync of zimbra folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder..." >> $ZimLogFile
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
rsync -avHK --delete --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
# Special LDAP DB copying needed.
$ZimInstPath/$ZimHome/openldap/bin/mdb_copy $ZimInstPath/$ZimHome/data/ldap/mdb/db $ZimFullTmpPath/$ZimHome/data/ldap/mdb/db >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder done." >> $ZimLogFile
 
# Starting Zimbra
179,13 → 188,15
else
 
# Hot sync before shutdown on zimbra folder
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath
rsync -avHK --delete --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath
 
# Stopping Zimbra
zimbra_stop
 
# Cold sync of zimbra folder
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath
rsync -avHK --delete --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath
# Special LDAP DB copying needed.
$ZimInstPath/$ZimHome/openldap/bin/mdb_copy $ZimInstPath/$ZimHome/data/ldap/mdb/db $ZimFullTmpPath/$ZimHome/data/ldap/mdb/db
 
# Starting Zimbra
zimbra_start
199,16 → 210,24
}
 
diff_backup() {
# Checking if LDAP database folder exist and fix it.
if [ ! -f "$ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db/data.mdb" ];
then
if [ ! -d "$ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db" ]
then
mkdir -p $ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db
fi
else
rm -R $ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db/data.mdb
fi
 
# Make backup
if [ $ZimLogEnable = 'yes' ] && [ $ZimLogVerbose = 'yes' ]
then
# Cleaning backup folder
#echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaning backup folder..." >> $ZimLogFile
#rm -r -f $ZimDiffTmpPath/* >> $ZimLogFile
#echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaning backup folder done." >> $ZimLogFile
 
# Hot syncing to backup folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder..." >> $ZimLogFile
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
rsync -avHK --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder done." >> $ZimLogFile
 
# Stopping Zimbra
216,17 → 235,14
 
# Cold syncing to backup folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder..." >> $ZimLogFile
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
rsync -avHK --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
# Special LDAP DB copying needed.
$ZimInstPath/$ZimHome/openldap/bin/mdb_copy $ZimInstPath/$ZimHome/data/ldap/mdb/db $ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder done." >> $ZimLogFile
 
# Starting Zimbra
zimbra_start
 
# Syncing backup folders
#echo "`date "+%Y-%m-%d %H:%M:%S"` - Syncing backup folders..." >> $ZimLogFile
#cp -R $ZimDiffTmpPath/* $ZimFullTmpPath/ >> $ZimLogFile
#echo "`date "+%Y-%m-%d %H:%M:%S"` - Syncing backup folders done." >> $ZimLogFile
 
# Compressing backup folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Compressing backup folder..." >> $ZimLogFile
tar -zcvpf $ZimBackupPath/$ZimBackupFile -C $ZimBackupPath td zimbra_version.txt >> $ZimLogFile
236,20 → 252,18
 
# Hot sync before shutdown on zimbra folder
#rm -R $ZimDiffTmpPath/*
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
rsync -avHK --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
 
# Stopping Zimbra
zimbra_stop
 
# Cold sync of zimbra folder
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
 
rsync -avHK --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
# Special LDAP DB copying needed.
$ZimInstPath/$ZimHome/openldap/bin/mdb_copy $ZimInstPath/$ZimHome/data/ldap/mdb/db $ZimDiffTmpPath/$ZimHome/data/ldap/mdb/db
# Starting Zimbra
zimbra_start
 
# Syncing files from diff to full backup folder
#cp -R $ZimDiffTmpPath/* $ZimFullTmpPath/
 
# Compressing backup for space reduction
tar -zcvpf $ZimBackupPath/$ZimBackupFile -C $ZimBackupPath td zimbra_version.txt
fi
559,14 → 573,6
fi
}
 
full_restore() {
echo "Full Restore under development"
}
 
diff_restore() {
echo "Diff Restore under development"
}
 
backup_file() {
# Checks what backup is choosen and sets file-name appropiate
 
/branches/1.0.x/readme.txt
1,4 → 1,4
oZimBackup v1.0.7 2015-12-14
oZimBackup v1.0.7 2016-04-01
----------------------------
 
Overview:
22,9 → 22,11
------
This script utilize rsync, tar & gzip for basic functionality but needs scp, ftp & expect for file transfers.
 
The script is pre-configured with some basic options. Open up the script in a text editor of your choice and change the options to suite your needs.
The script is pre-configured with some basic options, open up the script in a text editor of your choice
and change the options to suite your needs.
 
Has been tested with version 8.0.x of Zimbra Collaboration Suite - OSE but should even work with the latest 5.x, 6.x & 7.x OSE branch.
Has been tested with version 8.0.x & 8.6.x of Zimbra Collaboration Suite but should work on newer versions,
Will not work with earlier versions than 8.0.2 anymore, due to LDAP DB handling.
 
Disclaimer:
-----------