Subversion Repositories oZimbraBackup

Compare Revisions

Ignore whitespace Rev 5 → Rev 4

/branches/1.0.x/changelog.txt
1,15 → 1,8
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.
* oZimbraBackup.sh (core): Modified path to zmcontrol for startup and shutdown.
* oZimbraBackup.sh (core): Removed obsolete code.
* oZimbraBackup.sh (core): Removed obsolete code.
 
2014-05-18 Marcus Uddenhed <marcus@osource.se>
 
/branches/1.0.x/oZimbraBackup.sh
24,43 → 24,43
# Developer: oSource Development(as of 2009-07-01)
# DevTeam: Marcus Uddenhed
# Version: 1.0.7
# Updated: 2016-04-01 15:30
# Updated: 2015-12-14 22:17
#
 
#### Global Settings ####
ZimInstPath=/opt # Installation path for Zimbra, excluding the Zimbra folder.
ZimHome=zimbra # The Zimbra installation folder, excluding path to folder.
ZimInstPath=/opt # Installation path for Zimbra, excluding the Zimbra folder.
ZimHome=zimbra # The Zimbra installation folder, excluding path to folder.
ZimBackupPath=/opt/backup # Root folder for backup where backup files will be placed.
 
#### Log Settings ####
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/backup/logs # Folder for log files
ZimLogVerbose=no # Activates extra logging information(yes/no)
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
ZimLogVerbose=no # Activates extra logging information(yes/no)
 
#### File Transfer Settings ####
 
# Enable Services (yes/no)
ZimFtpEnable=no # Enable/Disable ftp file transfer(yes/no)
ZimScpEnable=no # Enable/Disable scp file transfer(yes/no)
ZimFtpEnable=no # Enable/Disable ftp file transfer(yes/no)
ZimScpEnable=no # Enable/Disable scp file transfer(yes/no)
 
# Extra FTP Settings
ZimFtpOpt='' # Extra options for ftp file transfer, see manual for ftp command
ZimFtpOpt='' # Extra options for ftp file transfer, see manual for ftp command
 
# Extra SCP Settings
ZimScpOpt='' # Extra options for scp file transfer, see manual for scp command
ZimScpOpt='' # Extra options for scp file transfer, see manual for scp command
 
# Common Settings
ZimFilehostUser= # Username for file transfers
ZimFilehostPass= # Password for file transfers
ZimFilehostAddress= # Host address for file transfers
ZimFilehostFolder= # Folder on host where files will be placed during file transfer
ZimFilehostUser= # Username for file transfers
ZimFilehostPass= # Password for file transfers
ZimFilehostAddress= # Host address for file transfers
ZimFilehostFolder= # Folder on host where files will be placed during file transfer
 
#### File Delete Settings ####
ZimDeleteLocalFile=no # Enable/Disable compressed backup file deletion after successful backup(yes/no)
ZimDeleteTimeSet=0 # Set in minutes above 0 to keep a desired amount of files locally,
# be sure to match the time with your backup schedules.
ZimDeleteTimeSet=0 # Set in minutes above 0 to keep a desired amount of files locally,
# be sure to match the time with your backup schedules.
 
##### Do not change anything below this line unless you know what you are doing #####
 
147,19 → 147,12
}
 
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 --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder done." >> $ZimLogFile
 
# Stopping Zimbra
167,13 → 160,11
 
# Cold sync of zimbra folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder..." >> $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
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder done." >> $ZimLogFile
 
# Starting Zimbra
zimbra_start
zimbra_start
 
# Compressing backup for space reduction
echo "`date "+%Y-%m-%d %H:%M:%S"` - Compressing backup folder..." >> $ZimLogFile
184,19 → 175,17
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaning differential backup folder..."
rm -r -f $ZimDiffTmpPath/* >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaned differential backup folder."
 
else
 
# Hot sync before shutdown on zimbra folder
rsync -avHK --delete --exclude 'data/ldap/mdb/db/data.mdb' $ZimInstPath/$ZimHome $ZimFullTmpPath
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath
 
# Stopping Zimbra
zimbra_stop
 
# Cold sync of zimbra folder
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
rsync -avHK --delete $ZimInstPath/$ZimHome $ZimFullTmpPath
 
# Starting Zimbra
zimbra_start
203,31 → 192,23
 
# Compressing backup for space reduction
tar -zcvpf $ZimBackupPath/$ZimBackupFile -C $ZimBackupPath tf zimbra_version.txt
 
# Cleaning differential folder.
rm -r -f $ZimDiffTmpPath/*
rm -r -f $ZimDiffTmpPath/*
fi
}
 
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 --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Hot syncing to backup folder done." >> $ZimLogFile
 
# Stopping Zimbra
235,14 → 216,17
 
# Cold syncing to backup folder
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cold syncing to backup folder..." >> $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
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath >> $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
252,18 → 236,20
 
# Hot sync before shutdown on zimbra folder
#rm -R $ZimDiffTmpPath/*
rsync -avHK --exclude 'data/ldap/mdb/db/data.mdb' --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
 
# Stopping Zimbra
zimbra_stop
 
# Cold sync of zimbra folder
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
rsync -avHK --compare-dest=$ZimFullTmpPath/ $ZimInstPath/$ZimHome $ZimDiffTmpPath
 
# 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
281,7 → 267,7
echo "`date "+%Y-%m-%d %H:%M:%S"` - Compressing backup folder..." >> $ZimLogFile
tar -zcvpf $ZimBackupPath/$ZimBackupFile -C $ZimBackupPath tmf zimbra_version.txt >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Compressing backup folder done." >> $ZimLogFile
 
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaning differential backup folder..."
rm -r -f $ZimMsgDiffTmpPath/* >> $ZimLogFile
echo "`date "+%Y-%m-%d %H:%M:%S"` - Cleaned differential backup folder."
292,7 → 278,7
 
# Compressing backup folder
tar -zcvpf $ZimBackupPath/$ZimBackupFile -C $ZimBackupPath tmf zimbra_version.txt
 
# Cleaning differential folder
rm -r -f $ZimMsgDiffTmpPath/*
fi
573,6 → 559,14
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 2016-04-01
oZimBackup v1.0.7 2015-12-14
----------------------------
 
Overview:
22,11 → 22,9
------
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 & 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.
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.
 
Disclaimer:
-----------