the capacity of one person or thing to react with or affect another in some special way, as by attraction or the facilitation of a function or activity.

Simple backup script for Single Server Zimbra Community

Posted on | July 11, 2014 | Comments Off on Simple backup script for Single Server Zimbra Community

This is just a simple script that I wrote to manage backing a singer server installation of Zimbra Community. It needs some attention, additional tests, etc. but works as is with zimbra 8.x on an ubuntu 12.04 server installation. Of course you will need to change ip addresses to suit your environment…

—– start of script —–

# 6.4.14
# run this as root
# should we run zmcontrol stop before we backup ldap
# exclude the ldap database directory from the rsync operation
# this assumes an ssh connection to the destination for the rsync

BACKUPLOG=’/opt/backuplog/backup_$(date +%a).log’

if [ x`whoami` != xroot ]; then
echo Error: must be run as root user
exit 1

# exit 0

# create a log file with the date2
# need to test for existence of directory – if not exist make the directory – then
touch /opt/backuplog/backup_$(date +”%a”).log
# set a start time
START1=$(date +%s)

# send the start time to the log file
echo “Time backup started = $(date +%a) $(date +%T)” >> /opt/backuplog/backup_$(date +%a).log

# execute the live sync…
# test for exist rsync – if not exit else then
# test for exist source and dest – if not either one – exit else
echo syncning files from $SOURCE to $DEST
$RSYNC_LOC -avH –exclude $EXCLUDE –delete $SOURCE $DEST

# set a finish live sync time and calculate the difference
FINISH1=$(date +%s)

# i will use the times to output to a log file later
echo “total time live rsync $(( ($FINISH1-$START1) / 60 )) minutes, $(( ($FINISH1-$START1) % 60 )) seconds” >> /opt/backuplog/backup_$(date +%a).log

# start the clock again
START2=$(date +%s)

# next backup the ldap databse to a local spot – may not work if there is a file there
# test for exist – if not exist – exit else


# now sync the database with the remote destination

# run rsync again to try and catch any files that might have been in use
# sync again – should not take long
$RSYNC_LOC -avH –exclude $EXCLUDE –delete $SOURCE $DEST

# here we should gather some info on the condition of the server, etc and stick it in the
log file.

FINISH2=$(date +%s)
echo “total time services down: $(( ($FINISH2-$START2) / 60 )) minutes, $(( ($FINISH2-$START2) % 60 )) seconds” >> /opt/backuplog/backup_$(date +%a).log

# Display Zimbra services status
echo “Displaying Zimbra services status” >> /opt/backuplog/backup_$(date +%a).log

su – zimbra -c/opt/zimbra/bin/zmcontrol status >> /opt/backuplog/backup_$(date +%a).log
# We need to clean up some things like removing the data.mdb file from /opt/ldapbackup because mdb_copy destination has to be empty

echo “Good bye” >> /opt/backuplog/backup_$(date +%a).log
exit 0

#### will grow this after some testing ####


Comments are closed.

  • About

    This website is supported by Ken Lombardi @ analogman consulting.
    phone: 253.two.two.two-7626
    email: ken@analogman'dot'org
    tweet: analogmanorg

  • Admin