Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Migration

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #201 (permalink)  
Old 07-16-2009, 12:11 AM
New Member
 
Posts: 3
Default

Hi tiger2000,

Thanks for the info: it's working !
Bye

Guillaume
Reply With Quote
  #202 (permalink)  
Old 08-14-2009, 08:46 AM
Advanced Member
 
Posts: 186
Talking

try this for migration of LDAP,mysql and zimbra

from zimbra to zimbra

Regards
Adeel
Reply With Quote
  #203 (permalink)  
Old 08-14-2009, 08:55 AM
raj raj is online now
Moderator
 
Posts: 768
Default

@adeelarifbhatti
seen your post to migrate zimbra..there are issues with it i will spend some time and write it up for you.
This thread i started 4 years back is to try to come up with "HOT" backup of OSS version.
We have tons of good ways to cold backup by "shutting down" zimbra (your is one of it)

Raj
__________________
i2k2 Networks
Dedicated & Shared Zimbra Hosting Provider
Reply With Quote
  #204 (permalink)  
Old 08-19-2009, 07:26 AM
Starter Member
 
Posts: 1
Default Restore

Is there a restore procedure?


Quote:
Originally Posted by mmarodin View Post
This is a per-user full backup script (based on mubley's code, 2005), for Zimbra 5.x. Zimbra DB and LDAP are also included.
I've tested it on 5.0.12 version.

I don't want to use ...
Code:
/opt/zimbra/bin/zmmailbox -z -m user@domain.com getRestURL “//?fmt=tgz” > /tmp/account.tgz
... because with this backup job I could not restore single messages, but only full mailbox.

I hope it could be usefull for you!

Code:
#!/bin/sh
#--------

# Backup Zimbra Open Source 5.x
# by mm@rodin - 20090206

# Modify the following variables to suit your installation
export time=`date +%y%m%d`
export backup_dir=/opt/backup
export zimbra_dir=/opt/zimbra
export index_dir=$zimbra_dir/index
export store_dir=$zimbra_dir/store

# We need mysqldump.  If it doesn't exist,
# copy mysql and modify it to call mysqldump.
if [ ! -e $zimbra_dir/bin/mysqldump ]; then
   cp $zimbra_dir/bin/mysql $zimbra_dir/bin/mysqldump
   sed -i 's|/bin/mysql |/bin/mysqldump |g' $zimbra_dir/bin/mysqldump
fi

# Create the backup directory
mkdir -p $backup_dir

# Get a list of all accounts and execute
# the contents of the for-loop for each account.
for i in `$zimbra_dir/bin/zmprov gaa` ; do

# Beginning of for-loop

#  Use email address to get zimbra_id
   zimbraId=`$zimbra_dir/bin/zmprov ga $i |grep zimbraId |sed 's|zimbraId: ||g'`
   set $zimbraId

#  Use mysql to get number id
   zimbra_nr=`$zimbra_dir/bin/mysql -e "use zimbra; select id from mailbox where account_id = '$1'"`
   zimbra_nr=`echo $zimbra_nr | sed 's|id ||g'`

#  Check to make sure we got a valid number id
   if [ "$zimbra_nr" = "" ]; then
      echo $i has no mailbox.
   else

#     Set zimbraAccountStatus to "maintenance"
      $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus maintenance

#     Marking user backup
      if [ ! -e $backup_dir/info-$zimbra_nr.txt ]; then
         echo "Zimbra ID:	$1" > $backup_dir/info-$zimbra_nr.txt
         echo "Mail address:	$i" >> $backup_dir/info-$zimbra_nr.txt
      fi

#     Backup index and store files
      tar -czf $backup_dir/$time-$zimbra_nr-data.tgz $zimbra_dir/index/0/$zimbra_nr $zimbra_dir/store/0/$zimbra_nr

#     Backup Mysql db
      $zimbra_dir/bin/mysqldump mboxgroup$zimbra_nr > $backup_dir/$time-$zimbra_nr.dump
      tar -czf $backup_dir/$time-$zimbra_nr.dump.tgz $backup_dir/$time-$zimbra_nr.dump
      rm -f $backup_dir/$time-$zimbra_nr.dump

#     Set zimbraAccountStatus to "active"
      $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus active

#  End of if statement
   fi

# End of for-loop
done

# Backup Zimbra master database and LDAP accounts database
# First, set all accounts to maintenance.
for i in `$zimbra_dir/bin/zmprov gaa` ; do
   $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus maintenance
done

$zimbra_dir/bin/mysqldump zimbra  > $backup_dir/$time-zimbra.dump
tar -czf $backup_dir/$time-zimbra.dump.tgz $backup_dir/$time-zimbra.dump
rm -f $backup_dir/$time-zimbra.dump

$zimbra_dir/bin/zmslapcat > $backup_dir/$time-zimbra.ldap
tar -czf $backup_dir/$time-zimbra.ldap.tgz $backup_dir/$time-zimbra.ldap
rm -f $backup_dir/$time-zimbra.ldap

# Setting all accounts to active mode.
for i in `$zimbra_dir/bin/zmprov gaa` ; do
   $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus active
done

# Backup complete
Reply With Quote
  #205 (permalink)  
Old 08-25-2009, 09:53 AM
Advanced Member
 
Posts: 191
Default

@ Raj.
In this case, where do you store the script written to backup all the users, backup a single user, and restore? I was thinking it should be in the /etc/cron
Please let me know I am trying to test this backup scenario. Especially the remote backup at 3am to another location within my network.

thanks
Reply With Quote
  #206 (permalink)  
Old 08-25-2009, 06:44 PM
raj raj is online now
Moderator
 
Posts: 768
Default

@borngunners: I guess you ment to ask this Q to the orignal poster of the script in this thread. i did not write the script or used it.

Full Server Backup and Restore of “open source version”

Raj
__________________
i2k2 Networks
Dedicated & Shared Zimbra Hosting Provider
Reply With Quote
  #207 (permalink)  
Old 02-04-2010, 07:41 AM
Starter Member
 
Posts: 1
Default Backup with mmarodins code

Quote:
Originally Posted by mmarodin View Post
This is a per-user full backup script (based on mubley's code, 2005), for Zimbra 5.x. Zimbra DB and LDAP are also included.
I've tested it on 5.0.12 version.

I don't want to use ...
Code:
/opt/zimbra/bin/zmmailbox -z -m user@domain.com getRestURL “//?fmt=tgz” > /tmp/account.tgz
... because with this backup job I could not restore single messages, but only full mailbox.

I hope it could be usefull for you!

Code:
#!/bin/sh
#--------

# Backup Zimbra Open Source 5.x
# by mm@rodin - 20090206

# Modify the following variables to suit your installation
export time=`date +%y%m%d`
export backup_dir=/opt/backup
export zimbra_dir=/opt/zimbra
export index_dir=$zimbra_dir/index
export store_dir=$zimbra_dir/store

# We need mysqldump.  If it doesn't exist,
# copy mysql and modify it to call mysqldump.
if [ ! -e $zimbra_dir/bin/mysqldump ]; then
   cp $zimbra_dir/bin/mysql $zimbra_dir/bin/mysqldump
   sed -i 's|/bin/mysql |/bin/mysqldump |g' $zimbra_dir/bin/mysqldump
fi

# Create the backup directory
mkdir -p $backup_dir

# Get a list of all accounts and execute
# the contents of the for-loop for each account.
for i in `$zimbra_dir/bin/zmprov gaa` ; do

# Beginning of for-loop

#  Use email address to get zimbra_id
   zimbraId=`$zimbra_dir/bin/zmprov ga $i |grep zimbraId |sed 's|zimbraId: ||g'`
   set $zimbraId

#  Use mysql to get number id
   zimbra_nr=`$zimbra_dir/bin/mysql -e "use zimbra; select id from mailbox where account_id = '$1'"`
   zimbra_nr=`echo $zimbra_nr | sed 's|id ||g'`

#  Check to make sure we got a valid number id
   if [ "$zimbra_nr" = "" ]; then
      echo $i has no mailbox.
   else

#     Set zimbraAccountStatus to "maintenance"
      $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus maintenance

#     Marking user backup
      if [ ! -e $backup_dir/info-$zimbra_nr.txt ]; then
         echo "Zimbra ID:	$1" > $backup_dir/info-$zimbra_nr.txt
         echo "Mail address:	$i" >> $backup_dir/info-$zimbra_nr.txt
      fi

#     Backup index and store files
      tar -czf $backup_dir/$time-$zimbra_nr-data.tgz $zimbra_dir/index/0/$zimbra_nr $zimbra_dir/store/0/$zimbra_nr

#     Backup Mysql db
      $zimbra_dir/bin/mysqldump mboxgroup$zimbra_nr > $backup_dir/$time-$zimbra_nr.dump
      tar -czf $backup_dir/$time-$zimbra_nr.dump.tgz $backup_dir/$time-$zimbra_nr.dump
      rm -f $backup_dir/$time-$zimbra_nr.dump

#     Set zimbraAccountStatus to "active"
      $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus active

#  End of if statement
   fi

# End of for-loop
done

# Backup Zimbra master database and LDAP accounts database
# First, set all accounts to maintenance.
for i in `$zimbra_dir/bin/zmprov gaa` ; do
   $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus maintenance
done

$zimbra_dir/bin/mysqldump zimbra  > $backup_dir/$time-zimbra.dump
tar -czf $backup_dir/$time-zimbra.dump.tgz $backup_dir/$time-zimbra.dump
rm -f $backup_dir/$time-zimbra.dump

$zimbra_dir/bin/zmslapcat > $backup_dir/$time-zimbra.ldap
tar -czf $backup_dir/$time-zimbra.ldap.tgz $backup_dir/$time-zimbra.ldap
rm -f $backup_dir/$time-zimbra.ldap

# Setting all accounts to active mode.
for i in `$zimbra_dir/bin/zmprov gaa` ; do
   $zimbra_dir/bin/zmprov ma $i zimbraAccountStatus active
done

# Backup complete

Hi Folks,

i know this thread is pretty old but i would like to tell you the needed corrections to be done to get it running because it hasnt been mentioned until now (i think ). We are testing zcs 6.04 FOSS on a 64bit Fedora11. As mentioned in some older posts the above script doesnt work 100% with newer releases of zcs. I have corrected the code and i think it works now. To get it running i had to change line 26 from:
"for i in `$zimbra_dir/bin/zmprov gaa` ; do"
to:
"for i in `$zimbra_dir/bin/zmprov -l gaa` ; do"
this has to be done 3 times, also in line 71 and line 84.
Then as mentioned by weigenmann on page 18 i changed line 76 (ignore the quotas):
from
"$zimbra_dir/bin/zmslapcat > $backup_dir/$time-zimbra.ldap"
to
"$zimbra_dir/libexec/zmslapcat > $backup_dir/$time-zimbra.ldap"
but then the generated file like weigenmann also realised only had following:
USAGE: zmslapcat <DIR>
I just removed the ">" (witout quotas) from the above line and that did the trick. But now you have to change the rm -f in line 77 to rm -rf because the script temporarily generates a folder now. Now when i unpack the tgz the file contains all the Infos from the ldap.
I am no scriptingguru but i think these small changes did it for us. Still one question keeps staying unanswered to me. Mmarodin mentioned that it should be possible to do message level restore could someone tell me how to do that? Any help is appreciated.

Best Regards

Needles
Reply With Quote
  #208 (permalink)  
Old 04-13-2010, 06:12 PM
Active Member
 
Posts: 34
Default

Excuse my ignorance, but how do I restore the server with this backup script? thanks
Reply With Quote
  #209 (permalink)  
Old 07-14-2010, 07:35 AM
Junior Member
 
Posts: 6
Default

Quote:
Originally Posted by halley View Post
Excuse my ignorance, but how do I restore the server with this backup script? thanks
Supporting halley.
Show please creaking recovery from such a backup.
Reply With Quote
  #210 (permalink)  
Old 11-18-2010, 11:39 AM
Loyal Member
 
Posts: 86
Default

Been using this script on Ubuntu with great success. Tried it today on CentOS5.5 64 but and get the following error on --INSTALL:
Quote:
touch: cannot touch `/etc/zmbak_v.0.8.sh/noread': Not a directory
chmod: cannot access `/etc/zmbak_v.0.8.sh/noread': Not a directory
Can't remember seeing this on Ubuntu. The crypt section is left as default:
Quote:
#--- Encryption Options ---#
# !! !!! !!! CRYPT is a legacy option and should best not be used for future compatibility !!! !!! !!
CRYPT="no" # valid answers are "yes" or "no" BEST IS LEFT AS IS
PASSDIR=/etc/`basename $0`/ # the directory the encryption hash is stored in.
PASSFILE="noread" # the file containing the password hash
so I don't know what I'm missing here...

Thanks for a great script, saved me twice already(HDD failures), now running a SAN with XenServer and drbd & heartbeat, so hopefully never will have downtime again. ;-)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.