Page 1 of 7 123 ... LastLast
Results 1 to 10 of 65

Thread: Simple backup script for OSE version

  1. #1
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default Simple backup script for OSE version

    I have made some overhaulin of my script and added file transfer functions, read below. The script can be downloaded <Here> for convenience.

    If any errors are found in the script post here and i will look into it right away.

    /Soulskater

    Changes as of 2008-03-08:
    -------------------------------------
    for those of you who have been using this script re-download the code since there has been some bug fixes, non critical but still.

    Following bug has been fixed:
    When running the msg option it created a extra folder called 0 in backup dir/store which resulted in double 0 folders in backup folder, ex,
    backdir/store/0/0 should have been backupdir/store/0.

    have been expirence some issues in ubuntu when running the script via crontab, though it is not limited to this script but rather an issue with the packaging with tar option, if you are running this script in crontab add following at the end of each line where you call this script, > /dev/nul 2>&1l ex.
    0 23 * * * /opt/scripts/ZimBackup.sh full > /dev/null 2>&1

    Changes as of 2008-03-09:
    -------------------------------------
    - Fixed issues with this script when running from crontab
    - added more backup options.

    Changes as of 2008-04-18:
    -------------------------------------
    Script has been updated with new functionality that enables file transfer with ftp & scp protocols.
    Last edited by soulskater; 04-18-2008 at 05:51 AM.
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

  2. #2
    phoenix is online now Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,581
    Rep Power
    57

    Default

    Quote Originally Posted by soulskater View Post
    Just made a script for backing up my OSE version of Zimbra and thought to share it with those who might want it. Have seen a couple of script popping up in the forum with backup scripts and wanted to share mine to.
    Another one, the more the merrier.

    Thanks for writing the script and posting it here, would you mind putting a copy of it on the wiki in the Backup & Restore section?
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default

    Thanks.

    Sure i will put it in the wiki, just have to figure out how.
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

  4. #4
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default

    Script has now been updated, see first post for latest version.
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

  5. #5
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default

    Another update, now the script should be ready for the wiki, will post when it is there.
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

  6. #6
    cornbread is offline Loyal Member
    Join Date
    Sep 2007
    Posts
    80
    Rep Power
    7

    Default ssh rsync

    I want to rsync resulting file/s should did I modify the the script properly?
    code is toward the bottom. I have the remote computer set up for automatic ssh authentication.


    Code:
    #!/bin/bash
    
    # This script will do various backups of Zimbra depending on wich you choose,
    # most of them are cold backups except the msg backup wich hot copies the 'store'
    # folder for possible individual mail retrival. Be sure to change the variables below
    # to point to where you got the zimbra folder and where you want it to be backed up to.
    #
    # This script must be run as root or a user with equal privileges or it will not work.
    #
    # Usage: ZimBackup.sh full	- For full backup (Cold)
    #	 ZimBackup.sh diff	- For diffrential backup (Cold)
    #	 ZimBackup.sh msgfull	- For complete message backup (Hot)
    #	 ZimBackup.sh msgdiff	- For diffrential message backup (Hot)
    #
    # When you run this script via crontab be sure to add '> /dev/null 2>&1' at the end
    # of the script like below or the tar command will fail for no apparent reason.
    # 00 12 * * * ZimBackup.sh full > /dev/null 2>&1
    #
    # Bits and pieces was adopted from a script created by Daniel W. Martin, 9 Sept 2007
    # Free to use and free of any warranty!  Marcus Uddenhed, 3 feb 2008
    #
    # Last updated: 2008-03-09
    
    ZimInstPath=/opt
    ZimHome=zimbra
    ZimBackupPath=/opt/backup
    ZimTempPath=/opt/backup/tmp
    
    # Do not change anything below this line unless you know what you are doing
    
    pre_check() {
    # Check to see if the tmp folder exist, and create if not
    mkdir -p $ZimTempPath
    
    # Check which zimbra version that is installed, for recovery purpose 
    sudo -u zimbra $ZimInstPath/$ZimHome/bin/zmcontrol -v > $ZimTempPath/zimbra_version.txt
    }
    
    full_backup() {
    # Removing possible old zimbra backup folder
    rm -r -f $ZimTempPath/$ZimHome
    
    # Stopping Zimbra
    /etc/init.d/zimbra stop
    sleep 20
    
    # Backing up zimbra folder
    cp -rv $ZimInstPath/$ZimHome $ZimTempPath/
    
    # Starting Zimbra
    /etc/init.d/zimbra start
    
    # Compressing backup for space reduction
    tar -zcvf $ZimBackupPath/ZimBackupTypeFull_`date +%Y%m%d%H%M`.tar.gz -C $ZimTempPath $ZimHome zimbra_version.txt
    }
    
    diff_backup() {
    # Hot sync before shutdown on zimbra folder
    rsync -avHK --delete $ZimInstPath/$ZimHome $ZimTempPath/
    
    # Stopping Zimbra
    /etc/init.d/zimbra stop
    sleep 20
    
    # Cold sync of zimbra folder
    rsync -avHK --delete $ZimInstPath/$ZimHome $ZimTempPath/
    
    # Starting Zimbra
    /etc/init.d/zimbra start
    
    # Compressing backup for space reduction and removing unpacked folder
    tar -zcvf $ZimBackupPath/ZimBackupTypeDiff_`date +%Y%m%d%H%M`.tar.gz -C $ZimTempPath $ZimHome zimbra_version.txt
    }
    
    msgfull_backup() {
    # Removing possible old store backup folder
    rm -r -f $ZimTempPath/store
    
    # Make dir for hot sync
    mkdir -p $ZimTempPath/store
    
    # Hot sync of mailbox messages
    rsync -avHK --delete $ZimInstPath/$ZimHome/store/0 $ZimTempPath/store/
    
    # Compressing store folder for space reduction
    tar -zcvf $ZimBackupPath/ZimBackupTypeMsg_`date +%Y%m%d%H%M`.tar.gz -C $ZimTempPath store zimbra_version.txt
    }
    
    msgdiff_backup() {
    # Make dir for hot sync
    mkdir -p $ZimTempPath/store
    
    # Hot sync of mailbox messages
    rsync -avHK --delete $ZimInstPath/$ZimHome/store/0 $ZimTempPath/store/
    
    # Compressing store folder for space reduction
    cd $ZimTempPath
    tar -zcvf $ZimBackupPath/ZimBackupTypeMsg_`date +%Y%m%d%H%M`.tar.gz -C $ZimTempPath store zimbra_version.txt
    }
    
    ################################
    rsync -e ssh -varuzP $ZimBackupPath/ remotemachine:/backup
    ################################
    
    case $1 in
    full)
    pre_check
    full_backup
    ;;
    diff)
    pre_check
    diff_backup
    ;;
    msgfull)
    pre_check
    msgfull_backup
    ;;
    msgdiff)
    pre_check
    msgdiff_backup
    ;;
    *)
    echo "Usage: ZimColdBackup.sh {full|diff|msgfull|msgdiff}"
    ;;
    esac

  7. #7
    dwmtractor's Avatar
    dwmtractor is offline Moderator
    Join Date
    Jul 2007
    Location
    San Jose, CA
    Posts
    1,027
    Rep Power
    10

    Exclamation Vote on FOSS hot backups

    Anyone interested in seeing backup options improve should vote on this poll initiated by Zimbra:

    Vote: Hot Backups for FOSS?

    Dan

  8. #8
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default

    Hi.

    Have tried you command with slightly changed parameters, only minor and it looks like it works, below is my line as a tested it from the console directly.

    rsync -e ssh -varuzP /opt/backup/ user@server:/destinationfolder/

    The diffrence is that i put a username to the line and can't see one in yours, can be due to editing the script for insertion here...

    Have you tried the script?
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

  9. #9
    uxbod's Avatar
    uxbod is offline Moderator
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    24

    Default

    If the same user, as the one performing the backup job, is on the remote server and the keys have been exchanged then a specified user should not be required.

    I second dwmtractor's comment, please vote on the FOSS backup poll

  10. #10
    soulskater's Avatar
    soulskater is offline Active Member
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    47
    Rep Power
    7

    Default

    True, but that was not the case in my enviorment.

    /soulskater
    Systems Specialist
    openSUSE Ambassador in Sweden
    Visit my blogs at www.osource.se

Page 1 of 7 123 ... LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 658
    Last Post: 04-04-2014, 09:01 AM
  2. Zimbra Backup Script ... Small Problem
    By frankb in forum Administrators
    Replies: 12
    Last Post: 07-14-2008, 08:40 AM
  3. Debian - Upgrade from 4.5.6
    By magikman in forum Installation
    Replies: 1
    Last Post: 01-19-2008, 12:59 PM
  4. Backup script issues
    By SSS in forum Administrators
    Replies: 18
    Last Post: 12-03-2007, 09:56 AM
  5. 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

Posting Permissions

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