Results 1 to 7 of 7

Thread: backing up zimbra via cron issues

  1. #1
    ben1967 is offline Senior Member
    Join Date
    Apr 2011
    Posts
    62
    Rep Power
    4

    Default backing up zimbra via cron issues

    Dear All

    I am using zimbra OSE 7.1.4 and I have 2 scripts which I just modified a little for my environment.
    the first creates a .tgz file
    and the second ftps this file to another machine.

    when I run them everything works great and no issues

    but when i run them via cron i face problems

    first zimbra does not start and also backup is not done
    i do backups in the night so in the morning i have to restart zimbra or maybe restart the machine

    i tried googlin arround but not achieve much

    here below my scripts
    the files are executables

    ---------

    #A Simple Shell Script Method

    #!/bin/bash

    # Zimbra Backup Script
    # This script is intended to run from the crontab as root

    # Outputs the time the backup started, for log/tracking purposes
    echo Time backup started = $(date +%T)
    before="$(date +%s)"

    rsync -avHK --delete /opt/zimbra/ /root/backup

    service zimbra stop
    sleep 25

    # Kill any orphaned Zimbra processes
    ORPHANED=`ps -u zimbra -o "pid="` && kill -9 $ORPHANED

    rsync -avHK --delete /opt/zimbra/ /root/backup

    service zimbra start
    # Calculates and outputs amount of time the server was down for
    after="$(date +%s)"
    elapsed="$(expr $after - $before2)"
    hours=$(($elapsed / 3600))
    elapsed=$(($elapsed - $hours * 3600))
    minutes=$(($elapsed / 60))
    seconds=$(($elapsed - $minutes * 60))
    echo Server was down for: "$hours hours $minutes minutes $seconds seconds"
    --------------------

    the second script

    --------------

    #!/bin/bash
    #
    USER="xxxxx"
    PASSWD="xxxxxxx"
    SERVER="192.168.100.33"
    ftp -n -i $SERVER << EOF
    user $USER $PASSWD
    prompt
    bin
    put /tmp/mail.backup.tgz
    bye

    ------------------------------------

    I really would appreciate if someone could advise me and help me out.
    do i have to rename the file with .sh extension???


    regards

    simon

  2. #2
    xero9 is offline Junior Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    3

    Default

    Good day Simon,

    What does the line in your crontab look like? I know it's something pretty basic, but are you calling the script by its full path? eg.

    0 2 * * * /opt/zimbra/scripts/backup.sh

    By the way, while I can't comment on every linux type system, I know under CentOS for example you don't require a .sh extension. As long as it's chmod +x on the file.

    When testing out cron jobs, I sometimes add to the top of the script a date > /tmp/date.txt and look for that file to see if the script is executing at all. It's one of my very basic debugging methods, but it does the trick sometimes

  3. #3
    ben1967 is offline Senior Member
    Join Date
    Apr 2011
    Posts
    62
    Rep Power
    4

    Default

    dear xero9,

    I really apprecite your quick reply
    i will check once again tonight and let you know since I can do any testing now

    regards and thanks once again

    simon

  4. #4
    lytledd is offline Elite Member
    Join Date
    Dec 2009
    Location
    Michigan
    Posts
    448
    Rep Power
    5

    Default

    service zimbra stop
    sleep 25
    I really don't think using service will work. This is what I do:

    Code:
    su - zimbra -c"/opt/zimbra/bin/zmcontrol stop"
    Doug
    Ben Franklin quote:

    "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."

  5. #5
    xero9 is offline Junior Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    3

    Default

    np Ben!

    lytledd is right though, after testing it myself, I'm able to do 'service zimbra stop' as root and it stops, but when trying through cron it doesn't actually work. Use his line instead, and that will at least stop Zimbra.

    Sorry, I am by no means an expert. Just thought I'd try and help out!

  6. #6
    ben1967 is offline Senior Member
    Join Date
    Apr 2011
    Posts
    62
    Rep Power
    4

    Default solved backing up zimbra via cron issue

    Its solved,
    Dear guys,

    I have solved the issue.
    first was changing from service zimbra stop and start to su - zimbra -c"/opt/zimbra/bin/zmcontrol stop" and start
    actually I am using centos 5.7
    the second was to specify the full path to rsync and tar
    also I changed my backup script extension to .sh but guess that does not matter

    after that i did find that the tar archive normally which is supposed to be abt 7.5 gb was stopping at some .5 gb

    so finally i found out that in the cron job I had to append confirm >/var/tmp/zbackup.log 2>&1

    /root/zimbra-back.sh confirm > /var/tmp/zbackup.log 2>&1

    and this worked flawlessly

    Thanks guys for all the help

    regards

    simon

  7. #7
    untnine is offline Junior Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    3

    Default

    Hi everyone,

    I backup my zimbra server and copied the files (backup files: mailboxes, master database and all files) to other server to test the consistency of the backup.

    First I copy all files: replaced the new zimbra files with those from the backup;
    Then I tried to import the master database to my new zimbra and had problems.

    Can some one help on this one???

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. backing up zimbra OSE
    By ben1967 in forum Administrators
    Replies: 2
    Last Post: 02-07-2012, 09:48 AM
  2. Replies: 1
    Last Post: 11-22-2010, 05:09 AM
  3. Backing Up Zimbra
    By djpic in forum Administrators
    Replies: 2
    Last Post: 03-19-2009, 05:51 PM
  4. Backing Up Zimbra
    By gforsyth in forum Installation
    Replies: 32
    Last Post: 02-24-2009, 02:30 PM
  5. Cron <root@fs1> run-parts /etc/cron.daily
    By demanl in forum Administrators
    Replies: 4
    Last Post: 04-23-2006, 06:14 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
  •