Page 44 of 66 FirstFirst ... 34424344454654 ... LastLast
Results 431 to 440 of 659

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

  1. #431
    Robin is offline Active Member
    Join Date
    Nov 2010
    Posts
    25
    Rep Power
    4

    Default

    I'm having problem running/installing the script.
    When I run
    Code:
    bis@mail:~$ /opt/scripts/zmbak_v.0.8.sh --INSTALL
    ^C
    bis@mail:~$
    Nothing more happens!? I have to exit with CTRL+C. Even tried running as root, but nothing.
    What can be wrong?

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

    Default

    Quote Originally Posted by Robin View Post
    Nothing more happens!? I have to exit with CTRL+C. Even tried running as root, but nothing.
    What can be wrong?
    Try
    Code:
    bash -n /opt/scripts/zmbak_v.0.8.sh
    to test the script without running it. Make sure the file is *nix-style, with LF for line endings.

  3. #433
    Robin is offline Active Member
    Join Date
    Nov 2010
    Posts
    25
    Rep Power
    4

    Default

    Nothing happens running
    Code:
    bash -n /opt/scripts/zmbak_v.0.8.sh
    Tried to convert it to *nix-style with
    Code:
    perl -pi -e 's/\r\n/\n/g' input.file
    but it doesn't make any difference.

  4. #434
    pinoy_steal is offline Senior Member
    Join Date
    Nov 2009
    Location
    Philippines
    Posts
    63
    Rep Power
    5

    Default

    Hi, I just want to implement 4 weeks retention period for backup. Then after that it will delete more than 4 weeks of backup.

    Can you help me how to modify this script so that the retention period are 4 weeks not only 2 weeks.

    [root@mail sbin]# diff -u zmbac.0.8.sh.orig zmbac.sh
    --- zmbac.0.8.sh.orig 2010-02-14 20:19:22.000000000 -0700
    +++ zmbac.sh 2010-03-23 18:15:24.000000000 -0600
    @@ -61,25 +61,25 @@
    #--- Directories ---#
    # Please add the trailing "/" to directories!
    ZM_HOME=/opt/zimbra/ # where zimbra lives
    -SYNC_DIR=/tmp/fakebackup/ # intermediate dir for hot/cold syncs. must have at least as much free space as ZM_HOME consumes
    -ARCHIVEDIR=/Backup/zimbra_dars/ # where to store final backups
    -TO_MEDIA_DIR=/Backup/burn/
    +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/

    #--- PROGRAM OPTIONS ---#
    RSYNC_OPTS="-aHK --delete --exclude=*.pid" # leave these unless you are sure you need something else

    #--- ARCHIVE NAMES ---#
    -BACKUPNAME="ZimbraBackup" # what you want your backups called
    +BACKUPNAME="Zimbra_Backup" # what you want your backups called
    FULL_PREFIX="FULL" # prefix used for full backups
    DIFF_PREFIX="DIFF" # prefix used for differential backups
    -BACKUPDATE=`date +%Y%m%d` # date format used in archive names
    -# BACKUPWEEK=`date +%W` # Week prefix used for backup weekly rotation and naming
    +BACKUPDATE=`date +%d-%B-%Y` # date format used in archive names
    +# BACKUPWEEK=`date +%V` # Week prefix used for backup weekly rotation and naming
    # VJS - Commented out above, and added below to allow Weekly baseline to be any day of week.
    # Needs full set of tests to be run, including archiving old weeks data, etc.
    BACKUPWEEKFILE="/opt/zimbra/backup.week"
    case $1 in
    -f | --full)
    -date +%W > $BACKUPWEEKFILE
    +date +%V > $BACKUPWEEKFILE
    ;;
    -d | --diff)
    if [ ! -e "$BACKUPWEEKFILE" ]
    @@ -95,7 +95,7 @@
    BACKUPWEEK=`cat $BACKUPWEEKFILE` # Week prefix used for backup weekly rotation and naming

    #--- ARCHIVE SIZE ---#
    -ARCHIVESIZE="4395M" # storage media size, for full-backup archiving
    +ARCHIVESIZE="110000M" # storage media size, for full-backup archiving
    # VJS - Uncomment next line for testing multi-DAR scenario on small mail store.
    #ARCHIVESIZE="50M" # storage media size, for full-backup archiving
    COMPRESS="9" # valid answers are 1 - 9 ( 9 = best )
    @@ -107,9 +107,9 @@
    PASSFILE="noread" # the file containing the password hash

    #--- Log Settings ---#
    -EMAIL="uesr@domain.ltd" # the address to send logs to
    +EMAIL="it@somewhere.com" # the address to send logs to
    # VJS - Added CC email to avoid errors sending report
    -EMAILCC="user@domain.ltd" # another address to send to, blank for none
    +#EMAILCC="user@domain.ltd" # 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?
    @@ -622,7 +622,41 @@
    fi
    done
    fi
    + # Remove previous week of backups from 2 weeks ago
    + TWO_WEEKS_AGO=$(expr "$BACKUPWEEK" \- 2)
    + LASTYEAR=$(expr `date +%Y` \- 1)
    + FINALWEEK=`date -d "$LASTYEAR"1228 +%V`
    + if [ "$BACKUPWEEK" -eq "1" ] ; then
    + TWO_WEEKS_AGO=$(expr "$FINALWEEK" \- 1)
    + elif [ "$BACKUPWEEK" -eq "2" ] ; then
    + TWO_WEEKS_AGO="$FINALWEEK"
    + elif [ "$TWO_WEEKS_AGO" -lt "10" ] ; then
    + TWO_WEEKS_AGO=0"$TWO_WEEKS_AGO"
    + fi
    + TWO_WEEK_BACKUP=`ls -A -1 "$TO_MEDIA_DIR" | grep "$TWO_WEEKS_AGO" | grep "$BACKUPNAME" | cut -d _ -f1 | head -n1`
    + if [ -z "$TWO_WEEK_BACKUP" ]
    + then
    + echo
    + echo "No two-week old backups found"
    + echo
    + else
    + echo
    + echo "Two-week old backup found...old week= "$TWO_WEEKS_AGO" current week= $BACKUPWEEK"
    + echo
    + for i in `ls -A -1 "$TO_MEDIA_DIR""$TWO_WEEKS_AGO"_"$BACKUPNAME"* `
    + do
    + rm $i
    + if [ "$?" -ne "0" ]
    + then
    + echo "Error during delete!"
    + else
    + echo "$i deleted"
    + fi
    + done
    + echo
    + fi
    fi
    +
    # Checking for a backup file collisions. Creating Date and Marker file.
    CURRENTNAME1=`ls -A -1 "$ARCHIVEDIR""$ARCHIVENAME"*dar 2> /dev/null | head -qn1`
    if [ -f "$CURRENTNAME1" ]
    Thanks.

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

    Default

    Quote Originally Posted by pinoy_steal View Post
    Hi, I just want to implement 4 weeks retention period for backup. Then after that it will delete more than 4 weeks of backup.

    Can you help me how to modify this script so that the retention period are 4 weeks not only 2 weeks.
    Well, you could use the cron method mentioned elsewhere, and change the number of days (adding 14):
    Code:
    55 19 * * 5 root find /backup/zimbrabak/*Zimbra_Backup* -mtime +29 -exec rm {} \;
    This deletes based on modification date, not any timestamp in the filename. For timestamp-based deletion, you could try this (instead of the TWO_WEEKS_AGO example):
    Code:
    + # Remove previous week of backups from 4 weeks ago
    + FOUR_WEEKS_AGO=$(expr "$BACKUPWEEK" \- 4)
    + LASTYEAR=$(expr `date +%Y` \- 1)
    + FINALWEEK=`date -d "$LASTYEAR"1228 +%V`
    + if [ "$BACKUPWEEK" -eq "1" ] ; then
    +   FOUR_WEEKS_AGO=$(expr "$FINALWEEK" \- 3)
    + elif [ "$BACKUPWEEK" -eq "2" ] ; then
    +   FOUR_WEEKS_AGO=$(expr "$FINALWEEK" \- 2)
    + elif [ "$BACKUPWEEK" -eq "3" ] ; then
    +   FOUR_WEEKS_AGO=$(expr "$FINALWEEK" \- 1)
    + elif [ "$BACKUPWEEK" -eq "4" ] ; then
    +   FOUR_WEEKS_AGO="$FINALWEEK"
    + elif [ "$FOUR_WEEKS_AGO" -lt "10" ] ; then
    +   FOUR_WEEKS_AGO=0"$FOUR_WEEKS_AGO"
    + fi
    + FOUR_WEEK_BACKUP=`ls -A -1 "$TO_MEDIA_DIR" | grep "$FOUR_WEEKS_AGO" | grep "$BACKUPNAME" | cut -d _ -f1 | head -n1`
    + if [ -z "$FOUR_WEEK_BACKUP" ]
    + then
    +   echo
    +   echo "No four-week old backups found"
    +   echo
    + else
    +   echo
    +   echo "Four-week old backup found...old week= "$FOUR_WEEKS_AGO" current week= $BACKUPWEEK"
    +   echo
    +   for i in `ls -A -1 "$TO_MEDIA_DIR""$FOUR_WEEKS_AGO"_"$BACKUPNAME"*`
    +   do
    +     rm $i
    +     if [ "$?" -ne "0" ] ; then
    +       echo "Error during delete!"
    +     else
    +       echo "$i deleted"
    +     fi
    +   done
    +   echo
    + fi

  6. #436
    pinoy_steal is offline Senior Member
    Join Date
    Nov 2009
    Location
    Philippines
    Posts
    63
    Rep Power
    5

    Default

    Hi Sir LaFong,

    Thank you for the quick reply. I try your suggestion.

  7. #437
    onze's Avatar
    onze is offline Active Member
    Join Date
    Jan 2010
    Location
    PT
    Posts
    28
    Rep Power
    5

    Default

    Hello,
    For security questions i have changed my backup server ssh port, can some please help me to identify the place in the script to specify that change?

    Thanks

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

    Default

    Quote Originally Posted by onze View Post
    Hello,
    For security questions i have changed my backup server ssh port, can some please help me to identify the place in the script to specify that change?
    Just use the -P option for the scp command:

    Code:
    [root@mail OLD]# diff -u zmbac.0.8.sh.orig zmbac.port.sh
    --- zmbac.0.8.sh.orig   2010-02-14 20:19:22.000000000 -0700
    +++ zmbac.port.sh       2011-01-06 11:25:10.000000000 -0700
    @@ -823,7 +823,7 @@
            then
                CPNAME=`ls -A "$ARCHIVENAME"*`
                echo "copy archive to $REMOTEHOST" remote directory $REMOTEDIR
    -           scp -i /root/.ssh/id_rsa $CPNAME "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
    +           scp -P 3333 -i /root/.ssh/id_rsa $CPNAME "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
                    if [ "$?" -ne "0" ]
                    then
                        echo "Error copying archive and checksum to $REMOTEHOST"
    Change the port from 3333 to your desired port.

  9. #439
    onze's Avatar
    onze is offline Active Member
    Join Date
    Jan 2010
    Location
    PT
    Posts
    28
    Rep Power
    5

    Default

    Hello LaFong,
    Thanks for the fast reply,
    I have spoted the scp in there but the following parameters have confused me.

    scp -i /root/.ssh/id_rsa $CPNAME
    "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
    It works perfectly.

    Thanks
    Last edited by onze; 01-07-2011 at 01:34 AM. Reason: Tested

  10. #440
    myriad's Avatar
    myriad is offline Active Member
    Join Date
    Oct 2008
    Location
    Toronto
    Posts
    46
    Rep Power
    6

    Default Problem with backup script

    I had originally set up the 'fakebackup' directory in the temp directory as suggested, but I found that the directory was erased on a system reboot and the script would fail. So I created a 'fakebackup' directory in the 'usr' directory and the script work perfectly for a month or so and then my system froze because the 'fakebackup' directory had grown so large it filled up all the available hard drive space and crashed the system!

    So back to the original directory I went (tmp) and now I am getting errors like this every time the cron runs:
    Writing a diff backup: 01_ZimbraBackup_20110108_DIFF
    into: /Backup/zimbra_dars/ with file sizes of max: 4395M
    Saving Unencrtyped Archive...
    FATAL error, aborting operation
    Badly formatted terminator, cannot extract catalogue location
    Dar had a problem!
    What can I do to fix this? When it works, it works well, but I don't have a backup as of a month ago and I am stumped as to how to fix it.

Page 44 of 66 FirstFirst ... 34424344454654 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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
  •