Results 1 to 6 of 6

Thread: [SOLVED] Asking about crontab when backing up zimbra ?

  1. #1
    Join Date
    Jun 2009
    Posts
    11
    Rep Power
    6

    Default [SOLVED] Asking about crontab when backing up zimbra ?

    Hi experts,

    I'm running Ubuntu 8.04.2 and Zimbra 5.0.16(both 64bit). I have configured Zimbra to be Domain Controller as well, things are going well now. But when I put 0 0 * * * /root/backup.sh -confirm this command into my crontab by using crontab -e by root user. After that I looked at my log backup file. It's only start my command until it noticed "stop zimbra successfull" and didn't make any backup files. It means some command after that couldn't start .I did this very very successfull while I was running on CentOS with Zimbra. But I prefer to use Ubuntu. Please trying to help me how to solve this problem. Anyway if I run my backup.sh directly by using "./root/backup.sh" on Ubuntu , it backed up successful.

    Many thanks

  2. #2
    Join Date
    Jun 2008
    Posts
    594
    Rep Power
    8

    Default

    What does this backup.sh does ? Why not use the standard zmbackup command which is default crontab when you install the server ? Second thing is you dont need to run backup as root user. It should be zimbra user.

  3. #3
    Join Date
    Jun 2009
    Posts
    11
    Rep Power
    6

    Default

    Thank you for your assistance, Veronica. But I'm running with Zimbra Open Source, so I don't have the way to backup using zmbackup. I'm using a simple backup like this

    #!/bin/bash

    # Zimbra Backup Script
    # Requires ncftp to run
    # This script is intended to run from the crontab as root
    # Date outputs and su vs sudo corrections by other contributors, thanks, sorry I don't have names to attribute!
    # Free to use and free of any warranty! Daniel W. Martin, 5 Dec 2008

    backuplog="/Data/Backup/backup.log"

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

    # Live sync before stopping Zimbra to minimize sync time with the services down
    # Comment out the following line if you want to try single cold-sync only
    rsync -avHK --delete /opt/zimbra/ /Data/Backup/zimbra

    # which is the same as: /opt/zimbra /backup
    # Including --delete option gets rid of files in the dest folder that don't exist at the src
    # this prevents logfile/extraneous bloat from building up overtime.

    # Now we need to shut down Zimbra to rsync any files that were/are locked
    # whilst backing up when the server was up and running.
    before2="$(date +%s)"

    # Stop Zimbra Services
    su - zimbra -c"/opt/zimbra/bin/zmcontrol stop"
    sleep 15

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

    # Only enable the following command if you need all Zimbra user owned
    # processes to be killed before syncing
    # ps auxww | awk '{print $1" "$2}' | grep zimbra | kill -9 `awk '{print $2}'`

    # Sync to backup directory
    rsync -avHK --delete /opt/zimbra/ /Data/Backup/zimbra

    # Restart Zimbra Services
    su - zimbra -c "/opt/zimbra/bin/zmcontrol 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" >> "$backuplog"

    # Create a txt file in the backup directory that'll contains the current Zimbra
    # server version. Handy for knowing what version of Zimbra a backup can be restored to.
    su - zimbra -c "zmcontrol -v > /Data/Backup/zimbra/conf/zimbra_version.txt"
    # or examine your /opt/zimbra/.install_history

    # Display Zimbra services status
    echo Displaying Zimbra services status...
    su - zimbra -c "/opt/zimbra/bin/zmcontrol status"

    # Create archive of backed-up directory for offsite transfer
    # cd /backup/zimbra
    tar -zcvf /Data/Backup/zimbra.backup-$(date +"%Y-%m-%d").tgz -C /Data/Backup/zimbra .

    # Outputs the time the backup finished
    echo Time backup finished = $(date +%T) >> "$backuplog"

    # Calculates and outputs total time taken
    after="$(date +%s)"
    elapsed="$(expr $after - $before)"
    hours=$(($elapsed / 3600))
    elapsed=$(($elapsed - $hours * 3600))
    minutes=$(($elapsed / 60))
    seconds=$(($elapsed - $minutes * 60))
    echo Time taken: "$hours hours $minutes minutes $seconds seconds" >> "$backuplog"

    Anyway I can run this backup.sh directly successful, the problem is when I put them in crontab using "crontab -e" like this

    0 0 * * * /Data/Backup/backup.sh -confirm

    and it can not backup successful, it seems to be failed at this command

    tar -zcvf /Data/Backup/zimbra.backup-$(date +"%Y-%m-%d").tgz -C /Data/Backup/zimbra .

    Could you please to look over them and give me how to fix this, I'm so appriciate with any of your helps

    Thanks

  4. #4
    Join Date
    Jan 2009
    Posts
    40
    Rep Power
    6

    Default

    I use the same backup script, the only diference is the tar command and I have put this on the root crontab:

    0 3 * * * /root/zimbrabackup.sh > /tmp/zmbackuplog.txt 2>&1

    Hope this helps.

    Regards.

  5. #5
    Join Date
    Jun 2009
    Posts
    11
    Rep Power
    6

    Default

    Thanks Enake, that's so good, I've aped and it's working now. Thank you for your help, many thanks, thounsand thanks, and thank you very much indeed.

    Wishing you're happy life always

  6. #6
    Join Date
    Jan 2009
    Posts
    40
    Rep Power
    6

    Default

    ;-)

    Excellent

    Regards.

Similar Threads

  1. [SOLVED] Zimbra logwatch.
    By nishith in forum Administrators
    Replies: 5
    Last Post: 06-10-2009, 05:42 PM
  2. [SOLVED] Clamav problem ? What's happening ?
    By aNt1X in forum Installation
    Replies: 23
    Last Post: 02-14-2008, 05:43 AM
  3. [SOLVED] Error Installing Zimbra on RHEL 5
    By harris7139 in forum Installation
    Replies: 10
    Last Post: 09-25-2007, 12:39 PM
  4. Zimbra shutdowns every n hours.
    By Andrewb in forum Administrators
    Replies: 13
    Last Post: 08-14-2007, 09:55 AM
  5. Fedora Core 3, Clean Install - Not working!
    By pcjackson in forum Installation
    Replies: 17
    Last Post: 03-05-2006, 07:38 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
  •