Page 21 of 22 FirstFirst ... 1119202122 LastLast
Results 201 to 210 of 211

Thread: Full Server Backup and Restore of “open source version”

  1. #201
    guillaume142 is offline New Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    7

    Default

    Hi tiger2000,

    Thanks for the info: it's working !
    Bye

    Guillaume

  2. #202
    adeelarifbhatti is offline Advanced Member
    Join Date
    Feb 2009
    Posts
    188
    Rep Power
    6

    Talking

    try this for migration of LDAP,mysql and zimbra

    from zimbra to zimbra

    Regards
    Adeel

  3. #203
    raj's Avatar
    raj
    raj is offline Moderator
    Join Date
    Oct 2005
    Location
    USA, Canada and India
    Posts
    777
    Rep Power
    10

    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

  4. #204
    tiagotavares is offline Starter Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    6

    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

  5. #205
    borngunners is offline Advanced Member
    Join Date
    Jun 2009
    Posts
    195
    Rep Power
    6

    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

  6. #206
    raj's Avatar
    raj
    raj is offline Moderator
    Join Date
    Oct 2005
    Location
    USA, Canada and India
    Posts
    777
    Rep Power
    10

    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

  7. #207
    Needles is offline Starter Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    5

    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

  8. #208
    halley is offline Senior Member
    Join Date
    Sep 2008
    Location
    Brazil
    Posts
    50
    Rep Power
    6

    Default

    Excuse my ignorance, but how do I restore the server with this backup script? thanks

  9. #209
    kharkov_max is offline Junior Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    5

    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.

  10. #210
    ekkas is offline Special Member
    Join Date
    Feb 2010
    Location
    South Africa
    Posts
    107
    Rep Power
    5

    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:
    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:
    #--- 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. ;-)

Page 21 of 22 FirstFirst ... 1119202122 LastLast

LinkBacks (?)

  1. 11-14-2007, 01:09 AM
  2. 08-13-2007, 04:01 AM
  3. 07-31-2007, 09:37 AM
  4. 06-08-2007, 10:09 AM
  5. 05-31-2007, 01:44 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mailbox backup & restore on open source version
    By Artturi in forum Administrators
    Replies: 3
    Last Post: 07-30-2010, 04:26 PM
  2. Restore single account failed from full backup
    By fmodola in forum Administrators
    Replies: 4
    Last Post: 06-20-2007, 05:27 AM
  3. 3 testing: LDAP: 389 Failed when restore zimbra
    By victorLeong in forum Administrators
    Replies: 15
    Last Post: 05-24-2007, 06:45 AM
  4. copying only last full backup to store offsite
    By riccadus in forum Administrators
    Replies: 0
    Last Post: 01-11-2007, 01:29 AM
  5. Zimbra Full Backup and Restore???
    By jgao in forum Administrators
    Replies: 3
    Last Post: 01-19-2006, 01:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •