Page 49 of 66 FirstFirst ... 39474849505159 ... LastLast
Results 481 to 490 of 659

Thread: [SOLVED] Yet Another Backup Script for Community Version

  1. #481
    LaFong is offline Advanced Member
    Join Date
    Nov 2008
    Location
    Denver, CO
    Posts
    221
    Rep Power
    6

    Default

    Quote Originally Posted by secnix View Post
    I've solved the problem, thanks . It's a little strange with the command
    Code:
    sudo -u zimbra /opt/zimbra/bin/zmcontrol start
    When I use it to start Zimbra, the service logger won't start. So I try the
    Code:
    su zimbra -c "zmcontrol start"
    then it works. Still wondering why
    What if you quote the command portion:
    Code:
    sudo -u zimbra "/opt/zimbra/bin/zmcontrol start"
    If that doesn't work, you could just substitute the su version for the sudo in the script. Here is a page describing the difference between sudo and su:
    What is the difference between SU and SUDO user commands
    Since the script is running as root anyway, I like the su approach better. For some people, sudo works just fine, depending on the distro and the contents of /etc/sudoers.

  2. #482
    secnix is offline Active Member
    Join Date
    Mar 2009
    Posts
    28
    Rep Power
    6

    Default

    Quote Originally Posted by LaFong View Post
    What if you quote the command portion:
    Code:
    sudo -u zimbra "/opt/zimbra/bin/zmcontrol start"
    If that doesn't work, you could just substitute the su version for the sudo in the script. Here is a page describing the difference between sudo and su:
    What is the difference between SU and SUDO user commands
    Since the script is running as root anyway, I like the su approach better. For some people, sudo works just fine, depending on the distro and the contents of /etc/sudoers.
    I'll try quoting the command you suggest. Thanks for the info about sudo and su.

    SN

  3. #483
    alex_rhys-hurn is offline Intermediate Member
    Join Date
    Nov 2009
    Posts
    20
    Rep Power
    5

    Default zmbak cant stop services zcs 7 FOSS ubuntu 10.04

    SOLVED: Disk was full

    Sorry folks, the below problems happened because the /tmp directory was too small, so the disk filled up causing all these issues. A real rookie mistake. Anyway ignore this.

    Alex

    Hello,

    I am using:
    OS: Ubuntu 10.04 LTS
    Zimbra: Release 7.0.0_GA_3077.UBUNTU10_64 UBUNTU10_64 FOSS edition.
    Zmbak: v0.8
    These are running on a vSphere 4.1 Virtual Machine

    I used ./zmback_v.0.8.sh --INSTALL to initially configure zmbak, and it created paths and installed mailx and dar and other utils.

    The only parts of the config I have changed are:

    Code:
    #--- Log Settings ---#
    EMAIL="alex@itworx.co.ke"       # the address to send logs to
    # VJS - Added CC email to avoid errors sending report
    EMAILCC="support@itworx.co.ke"                          # another address to send to, blank for none
    LOG="/var/log/zim_backup.log"   # log location
    # VJS - Added chewitt suggestion for optional listing on report email
    ATTACHLIST="no"                 # attach backup file or not?
    # VJS - Added FILTERLIST to remove all except changed or removed files from the listing
    FILTERLIST="yes"  # Answer "yes" or "no" - "no" lists everything. "yes" filters out unchanged files.
    and

    Code:
    #--- SSH REMOTE DR COPY ---#
    # This option will secure copy your archives to a remote server via 'scp'
    DRCP="yes"              # valid answers are "yes" or "no"
    SSHUSER="mailbackup"    # recommend creating a user on the remote machine just for transferring backups
    SSHKEY="rsa"    # recommended answers are "rsa" or "dsa" but "rsa1" is also valid.
    REMOTEHOST="192.168.128.172"    # can use IP too
    REMOTEDIR="/volumes/itworx-pool/groupware.itworx.co.ke-backup"  # where you want your backups saved.
    But when I run the command from the console with

    ./zmbak_v.0.8.sh -f

    I get failures to stop the services. Also it says sendmail is missing.

    Why is that? What can I do / what have I done wrong?

    Code:
    ============================
    Fri Apr 29 08:22:24 EAT 2011
    Performing FULL backup
    ============================
    full Backup started at: Fri Apr 29 08:22:24 EAT 2011
    No old backups found
    Setting date & version Marker into /opt/zimbra/DATE_VERSION.txt
    Doing a hotsync of /opt/zimbra/ to /tmp/fakebackup/
    rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Broken pipe (32)
    rsync: write failed on "/tmp/fakebackup/zmstat/2011-02-23/mysql.csv.gz": No space left on device (28)
    rsync error: error in file IO (code 11) at receiver.c(302) [receiver=3.0.7]
    rsync: connection unexpectedly closed (1867429 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]
    rsync threw a hotsync error. this is not unusual, continuing...
    Disabling the Zimbra crontab...
    Stopping the Zimbra server...
    
    Host
            Stopping stats...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping mta...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping spell...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping snmp...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping cbpolicyd...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping archiving...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping antivirus...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping antispam...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping imapproxy...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping memcached...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping mailbox...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping logger...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping zmconfigd...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    
            Stopping ldap...sh: cannot create zmcontrol.out.h_nGI: Permission denied
    cat: zmcontrol.out.h_nGI: No such file or directory
    Failed.
    
    zmcontrol shutdown had an error!
    /usr/lib/sendmail: No such file or directory
    "/root/dead.letter" 10/288
    . . . message not sent.
    Help appreciated. Thanks,

    Alex
    Last edited by alex_rhys-hurn; 04-29-2011 at 12:32 AM.

  4. #484
    dipeshmehta is offline Special Member
    Join Date
    Jun 2010
    Location
    Rajkot, India
    Posts
    160
    Rep Power
    5

    Default

    Hello All,

    I have been successfully using zmbak script for my Zimbra 7.0.1 FOSS on Ubuntu 8.04 in production environment.

    Now we are planning upgrade to Network Edition. Although, the backup feature is there in NE, I would like to know, if this script runs with NE as well? The reason is that the script has been found working OK and backup/restore were tested thoroughly before putting into production.

    Dipesh

  5. #485
    LaFong is offline Advanced Member
    Join Date
    Nov 2008
    Location
    Denver, CO
    Posts
    221
    Rep Power
    6

    Default

    Quote Originally Posted by dipeshmehta View Post
    Hello All,
    I would like to know, if this script runs with NE as well?
    It should work. I am not running 7.x yet, but it seems lots of others are, and the script is working for them. The basic script is just a zimbra directory duplication, so there's little chance of anything breaking. The DB backup I added will probably work, too, but I have not tested with 7.x.

  6. #486
    dipeshmehta is offline Special Member
    Join Date
    Jun 2010
    Location
    Rajkot, India
    Posts
    160
    Rep Power
    5

    Default

    Quote Originally Posted by LaFong View Post
    It should work. I am not running 7.x yet, but it seems lots of others are, and the script is working for them. The basic script is just a zimbra directory duplication, so there's little chance of anything breaking. The DB backup I added will probably work, too, but I have not tested with 7.x.
    Thanks friend,

    I would check it in test environment prior to put in production.

    Dipesh

  7. #487
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    710
    Rep Power
    6

    Default Avoid Disk Full on Remote Copy

    While my zimbra server has lots of space for keeping multiple weeks of backups, the remote server I use for offloading a copy does not. Twice I have ended up filling the hard drive on the remote system - causing problems on that server. So, I decided to see if I could figure out a way to make sure it doesn't happen again. This works for me, hopefully it might be of use to some of you too. It uses awk, and will only work if the remote system is also a linux system (I use it on CentOS)

    At the top of zmbak.sh - find the section
    Code:
    #--- SSH REMOTE DR COPY ---#
    # This option will secure copy your archives to a remote server via 'scp'
    DRCP="yes"		# valid answers are "yes" or "no"
    and add two more lines at the bottom of the section
    Code:
    REMOTEVOL="VolGroup00-LogVol00"     # volume on remote host where backups will be saved 
    REMOTEMINFREE=200000                # Required minimum 1K disks blocks free after copy (Approx 200MB in this case)
    Then, search to near the bottom of the script where you will find
    Code:
    	# DRCP Section. To scp newly created archives to a remote system
    	if [ "$DRCP" = "yes" ]
    	then
    After the "then", add the following code

    Code:
    		echo "Checking disk space on volume [$REMOTEVOL] on host [$REMOTEHOST]"
    		needed=$(find $ARCHIVEDIR -name "$ARCHIVENAME*" -exec ls -sk  {} \; | awk '{ s+=$1 } END { print s }')
    		avail=$(ssh $SSHUSER@$REMOTEHOST df -P -k | grep -i $REMOTEVOL | awk '{ print $4 }')
    		surplus=$(expr $avail - $needed)
    		if [ $surplus -ge $REMOTEMINFREE ]; then
    			echo "Avail:"$avail "- Needed:"$needed "- Surplus:"$surplus "- MinFree:"$REMOTEMINFREE "- OK TO COPY"
    			echo "Begin copy ..."
    		fi
    		if [ $surplus -lt $REMOTEMINFREE ]; then
    			echo "Avail:"$avail "- Needed:"$needed "- Surplus:"$surplus "- MinFree:"$REMOTEMINFREE "- CANNOT COPY"
    			echo "Error NOT ENOUGH SPACE AVAILABLE to copy backup files to $REMOTEHOST"
    			exit 1
    		fi
    This code will get the total number of 1K blocks needed to copy the current backup, and then the total number of 1K blocks available on the specified volume on the remote host. It then subtracts the needed from the available to give a surplus (which could be negative of course) and checks to see if that surplus is larger than the configured value for the minimum number of free blocks on the remote volume.

    NOTE: REMOTEVOL="VolGroup00-LogVol00"
    This does not need to be the complete volume name as listed by df (in my case that is /dev/mapper/VolGroup00-LogVol00) - it just needs to be enough to uniquely identify the volume from the df output.

    TODO: If anyone knows a way to find the remote volume name using the remote directory name - the configuration could be simplified further to just adding the Minimum Free Blocks setting. - Please reply back if there is way to do it.

  8. #488
    123456789 is offline New Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    4

    Unhappy download problems

    Quote Originally Posted by LaFong View Post
    Since I got a rousing response of 1 inquiry to my post about adding per-user backup to this script, I thought I'd just go ahead and post it.

    Here are the changes. In the main backup script, add the lines with the + in them (leaving out the +, of course).

    Code:
    --- OLD/zmbac.0.8.sh.orig       2010-02-14 20:19:22.000000000 -0700
    +++ zmbac.sh    2010-05-16 14:43:40.000000000 -0600
    @@ -61,25 +61,26 @@
     #--- Directories ---#
     # Please add the trailing "/" to directories!
     ZM_HOME=/opt/zimbra/   # where zimbra lives
     SYNC_DIR=/backup/sync/ # intermediate dir for hot/cold syncs. must have at least as much free space as ZM_HOME consumes
     ARCHIVEDIR=/backup/current/    # where to store final backups
     TO_MEDIA_DIR=/backup/previous/
    + SCRIPT_DIR=/usr/local/sbin/  # where zmbac.sh and zmDBbac.sh reside
     
     
    @@ -129,6 +130,9 @@
     #Hack to start Stats, even run zmlogprocess if needed
     STATHACK="yes"                 # valid answers are "yes" or "no"
     
    +#--- Dump Databases? ---#
    +# Adjust zmDBbac.sh script to backup up per-user or raw dbs, or both.
    +DUMP_DBS="yes"                 # valid answers are "yes" or "no"
     
     ## ~~~~~!!!! SCRIPT RUNTIME !!!!!~~~~~ ##
     # Best you don't change anything from here on, 
    
    @@ -695,6 +764,28 @@
                mail_log
                    exit 1
         fi
    +       # Dump DB's, if enabled
    +       if [ $DUMP_DBS = "yes" ] ; then 
    +           echo
    +           # Create db_dumps directory
    +           if [ ! -d $SYNC_DIR"db_dumps" ] ; then
    +              echo "Creating db_dumps directory..."
    +              chmod 755 $SYNC_DIR
    +              mkdir $SYNC_DIR"db_dumps"
    +              chown $ZM_USER $SYNC_DIR"db_dumps"
    +           fi
    +           # Run script to dump dbs
    +           echo "Backing up Zimbra DBs..."
    +           su - $ZM_USER -c $SCRIPT_DIR"zmDBbac.sh $SYNC_DIR"
    +           if [ "$?" -ne "0" ] ; then
    +             echo "There was an error running DB backup script! Aborting DB backup. Continuing main backup."
    +           fi
    +	    # Check that /opt/zimbra/db_dumps exists, or create empty /opt/zimbra/db_dumps directory tree if necessary
    +           if [ ! -d $ZM_HOME"db_dumps" ] && [ -d $SYNC_DIR"db_dumps" ] ; then
    +             $RSYNC_BIN -a -f"+ */" -f"- *" $SYNC_DIR"db_dumps" $ZM_HOME
    +           fi
    +       fi
    +       echo
         # Starting the Zimbra server again
        # Reinstate zimbra user's crontab
            echo "Reinstating Zimbra's crontab..."
    These changes set the script directory, enable DB backups, then call the DB backup script.

    You can download the db backup script at: zmDBbac.sh

    Backup

    1. Put the zmDBbac.sh script in the same directory as zmbac.sh
    2. Make it executable:
    Code:
    chmod 755 zmDBbac.sh
    3. Make any changes to settings in the zmDBbac.sh script. These are
    • Create processed DB dump, with added SQL commands to ease restore. (default)
    • Create RAW db dump, with no processing. (optional. Since you can convert a processed db dump back to raw using the 'makeraw' option in this script, raw dumps should not be needed. Raw db's are handy for individual folder restore.)
    • Specify a domain DN to back up. (optional)
    • Specify a COS to back up (optional)

    4. The zmDBbac.sh script will create several folders. It creates a db_dumps directory in your SYNC_DIR directory, with ldap, raw, and mailboxes subdirectories. It creates these same folders in /opt/zimbra. The directories in /opt/zimbra remain empty always, and are merely used by rsync to empty the directories in SYNC_DIR/db_dumps every night.

    In your nightly email from the script, it will show the db dump results:
    Code:
    ============================
    Wed May 5 03:00:02 MDT 2010
    Performing DIFF backup
    ============================
    <etc>
    Doing a fast cold sync...
    
    Backing up Zimbra DBs...
    Making sure all Zimbra services are stopped
    Starting just LDAP and MySQL for db dump...
    Starting LDAP...
    Started slapd: pid 27636
    Starting MySQL...
    Starting mysqld...done.
    Trying to connect to MySQL...
    
    Dumping and processing per-user dbs and exporting per-user LDAP entries...
    E-Mail                            User DB        LDAP        zimbraId
    ------                            -------        ----        -------
    (zimbra)                          zimbra         --          60fa3489-9854-22d9-8f21-000a67a98ef2
    Alise.Amadeo@somewhere.com        mboxgroup11    11.ldif     71c8a11d-02ec-c29c-9dd9-b49c80600ca5
    Bernetta.Verdin@somewhere.com     mboxgroup2     2.ldif      2705a240-07fe-cccc-acfd-cc26c489c293
    Caitlin.Kellman@somewhere.com     mboxgroup45    45.ldif     67a60dca-07ad-c66a-9d6f-9f7832d29440
    Cassey.Antczak@somewhere.com      mboxgroup42    42.ldif     fc4fc12d-b16e-c91d-ae3d-b6b86a72826c
    Cecile.Lorenz@somewhere.com       mboxgroup12    12.ldif     6d0ec99f-c70e-caa8-afaa-e48ca98cae59
    Chau.Gable@somewhere.com          mboxgroup43    43.ldif     8dfe7a6f-0b9f-cbff-9b8c-e1f5b860c3b8
    Dannie.Weatherman@somewhere.com   mboxgroup88    88.ldif     f6ddd11c-ce1a-c6b9-a3ad-164762d5c8d3
    <etc>
    Total users = 88
    Stopping LDAP and MySQL...
    Stopping mysqld... done.
    Killing slapd with pid 27636 done.
    
    Reinstating Zimbra's crontab...
    Starting Zimbra...
    Host mail.somewhere.com
    	Starting ldap...Done.
    	Starting logger...Done.
    	Starting mailbox...Done.
    	Starting antispam...Done.
    	Starting antivirus...Done.
    	Starting snmp...Done.
    	Starting spell...Done.
    	Starting mta...Done.
    	Starting stats...Done.
    Service down time was - Hr:0 Min:7 Sec:39
    <etc>
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    diff Zimbra Backup ended at: 03:33
    Backup took Hr:0 Min:33 Sec:43 to complete
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    Restore

    You can find the user's id from the nightly email, or in /mysyncdir/db_dumps/namelist.txt
    Restoring user "12" would go like:

    1. Be sure you have a good backup.
    2. Delete the user, if necessary. (For example, you are restoring the user because their user db is corrupt.)
    3. Restore the user's message store to /opt/zimbra/store/0/12
    4. Restore the user's index to /opt/zimbra/index/0/12
    5. As Zimbra user, restore user's db and zimbra db records:
    Code:
    mysql < /mysyncdir/db_dumps/mailboxes/12.sql
    6. Restore the user's LDAP entry, if necessary. As zimbra user (changing paths and host as necessary):
    Code:
    source ~/bin/zmshutil ; zmsetvars
    /opt/zimbra/openldap/bin/ldapadd -D "uid=zimbra,cn=admins,cn=zimbra" -f /mysyncdir/db_dumps/mailboxes/12.ldif -w "$zimbra_ldap_password" -x -H ldap://myzimbraserver.somewhere.com
    As previously stated:
    • This script must do the db dumps cold, which adds a few, to several, minutes of downtime during backup.
    • This script also does the LDAP user backup cold. Cold LDAP backups add a minute or two to server downtime for small servers. For larger servers, the LDAP backup could be moved to the main backup script, and be done hot.
    • I have done several successful test restores to a secondary server, but have not thoroughly tested every aspect of it. It would be wise to try test restores on a non-production server.
    I'm a novice and I have learned a lot with your help. Thank you.

    I would like to restore one user message box ...

    I tried to download the zmDBbac.sh script but the server where this link points have problems. So, it's impossible for me to download the script. Do you have this script elsewhere ? The file download is useless, is't all ways truncated and does not start correctly because i got a lot of server warning messages

    Many thanks

  9. #489
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    710
    Rep Power
    6

    Default

    I would like to restore one user message box ...

    I tried to download the zmDBbac.sh script but the server where this link points have problems. So, it's impossible for me to download the script. Do you have this script elsewhere ? The file download is useless, is't all ways truncated and does not start correctly because i got a lot of server warning messages
    If you already in the position where you need to restore a user's mailbox, you are too late to be looking to download the database backup script.

    Please explain exactly what has happened, what backups you do have, and what you need to do, and perhaps someone can help you.

  10. #490
    123456789 is offline New Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    4

    Default

    Quote Originally Posted by liverpoolfcfan View Post
    If you already in the position where you need to restore a user's mailbox, you are too late to be looking to download the database backup script.

    Please explain exactly what has happened, what backups you do have, and what you need to do, and perhaps someone can help you.
    Thank you for your time.
    At this moment nothing happed yet. Thanks God. But, just in case of ... you know ...

    I would like to have a good net before starting to use zimbra. So I started to search for a good backup & restore software because here we have zimbra FOSS (ZCS Open Source Edition), almost ready to start.

    The zmbak_v.0.8.sh script is a very good disaster recover solution but ...

    If some user deleted some mails and then after some time after, ask us for help ... then what ?

    I guess, I gotta find a way to have a safeguard that allows us to easily retrieve mail from a particular account and restore it.

Page 49 of 66 FirstFirst ... 39474849505159 ... LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Zimbra Backup Script ... Small Problem
    By frankb in forum Administrators
    Replies: 12
    Last Post: 07-14-2008, 08:40 AM
  2. Debian - Upgrade from 4.5.6
    By magikman in forum Installation
    Replies: 1
    Last Post: 01-19-2008, 12:59 PM
  3. Backup script issues
    By SSS in forum Administrators
    Replies: 18
    Last Post: 12-03-2007, 09:56 AM
  4. 4.0.4 to 4.5.6 upgrade failed in network edition
    By chenthil in forum Administrators
    Replies: 1
    Last Post: 08-27-2007, 09:36 AM
  5. [SOLVED] Simple backup question...
    By dameron in forum Administrators
    Replies: 3
    Last Post: 08-25-2007, 09:36 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
  •