Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 35

Thread: [SOLVED] Backup on Open Source Edition

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

    Smile OK, here is the simplest backup script you can get!

    Thanks to everyone for your feedback and help. This is the resultant COLD BACKUP script, which is about as dumb-stupid as you can get, but I can testify that it DOES work, because I blew up my system (RAID controller rebuilt an empty drive over my ZCS-installed drive ) and I used the results of this backup to restore my server to working condition!

    In my test the Zimbra server was down for about five minutes during the sync process, and then was back up while the system made its offsite backup file and sent it away (thanks mmorse for that useful suggestion). It'll sync faster once it's just resyncing the backup directory, but it'll be slower again depending on how many users/messages are changed, so I'll be interested to see how fast it works over time.

    Here's the script:
    Code:
    # Zimbra Backup Script
    # Requires ncftp to run
    # This script is intended to run from the crontab as root
    # Free to use and free of any warranty!  Daniel W. Martin, 27 Aug 2007
    
    # Stop Zimbra Services
    sudo -u zimbra /opt/zimbra/bin/zmcontrol stop
    sleep 15
    
    # Sync to backup directory
    rsync -avrlHKpogDt /opt/zimbra/ /backup/zimbra
    
    # Restart Zimbra Services
    sudo -u zimbra /opt/zimbra/bin/zmcontrol start
    
    # Create archive of backed-up directory for offsite transfer
    cd /backup/zimbra
    tar -zcvf /tmp/mail.backup.gz *
    
    # Transfer file to backup server
    ncftpput -u <username> -p <password> <ftp servername> /mail /tmp/mail.backup.gz

  2. #12
    maerten is offline Awaiting Activation
    Join Date
    Aug 2007
    Posts
    12
    Rep Power
    0

    Default

    You can do it even with less offline time by syncing online, stop zimbra, sync offline, start zimbra

  3. #13
    fajarpri's Avatar
    fajarpri is offline Loyal Member
    Join Date
    Jul 2007
    Posts
    98
    Rep Power
    8

    Default

    About the rsync parameter, I think nowadays the parameter 'a' replaces the whole above mentioned parameters?
    So, it's just enough: rsync -a

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

    Default Script edits

    Quote Originally Posted by maerten View Post
    You can do it even with less offline time by syncing online, stop zimbra, sync offline, start zimbra
    Good idea, Maerten, at least in theory. I tested it (although admittedly with a small server) and I didn't find a significant time saving on the second sync--your mileage may vary. I presume the reason the "down" sync takes as long as it does has to do with a significant number of working files that must be removed in the non-live second sync.

    I had already observed, by the way, that a live sync, or even a sync immediately after downing Zimbra services, resulted in some oddball Postfix files (I presume they're some sort of working files, though I don't know) that tar couldn't handle and bombed. That's why I put the "sleep" command after downing Zimbra and before running the sync, to make sure the services were fully stopped and pids cleaned up before syncing the real files.

    Quote Originally Posted by fajarpri View Post
    About the rsync parameter, I think nowadays the parameter 'a' replaces the whole above mentioned parameters?
    So, it's just enough: rsync -a
    Fajarpri, I checked the rsync man page at rsync and you're almost right:

    -a, --archive archive mode; same as -rlptgoD (no -H)
    That means the l, H, and K options mmorse recommended aren't part of -a. I should think these are valuable options to preserve:

    -l, --links copy symlinks as symlinks
    -K, --keep-dirlinks treat symlinked dir on receiver as dir
    -H, --hard-links preserve hard links
    Of course the -v option is totally optional; it's worth having when you're watching the script unfold as it tells you it's working; it's unnecessary in a nonlive backup situation. "You pays your money and you takes your choice" as they say.

    So I should revise the script to
    Code:
    rsync -alHK
    to maintain all the options mmorse recommended while not being redundant. Thanks for the pointers to clean it up!

    So for ease of reading/editing, here's the REVISED script in its entirety:

    Code:
    # Zimbra Backup Script
    # Requires ncftp to run
    # This script is intended to run from the crontab as root
    # Free to use and free of any warranty!  Daniel W. Martin, 27 Aug 2007
    
    # Live sync before stopping Zimbra to minimize sync time with the services down
    # Comment out this line if you want to try single cold-sync only
    rsync -avlHK /opt/zimbra/ /backup/zimbra
    
    # Stop Zimbra Services
    sudo -u zimbra /opt/zimbra/bin/zmcontrol stop
    sleep 15
    
    # Sync to backup directory
    rsync -avlHK /opt/zimbra/ /backup/zimbra
    
    # Restart Zimbra Services
    sudo -u zimbra /opt/zimbra/bin/zmcontrol start
    
    # Create archive of backed-up directory for offsite transfer
    # cd /backup/zimbra
    tar -zcvf /tmp/mail.backup.gz *
    
    # Transfer file to backup server
    ncftpput -u <username> -p <password> <ftpserver> /<desired dest. directory> /tmp/mail.backup.gz
    root@mail:/etc#
    Note also that your ftpserver must either be in your /etc/hosts file, resolvable by a nameserver, or else put in this script as an ip address. . .

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

    Default Clean up unnecessary files?

    As I watched this backup run, I noticed I have some REALLY huge files that take their sweet time on both rsync and tar, and which seem to me like they may be superfluous anyhow. Can anyone tell me if there's any necessity to back up logfiles? Specifically zmmtaconfig.log is huge, and this thread http://www.zimbra.com/forums/adminis...onfig-log.html says it's safe to delete. I'm thinking I might exclude /opt/zimbra/log/* from the rsync; is that safe?

    Also in /opt/zimbra/db/data there are two log files ib_logfile0 and ib_logfile1 that are each about a gig in size, though I see that ib_logfile0 has today's date on it (the other is already a month old). Are these important, or also excludable from a backup?

    I realize I'm kinda asking the same question that started this whole thread, and I don't want to create the digital equivalent of a doorstop out of my backup file, but I also don't want to waste resources backing up true junk.

    Suggestions?

  6. #16
    mmorse's Avatar
    mmorse is offline Moderator
    Join Date
    May 2006
    Location
    USA
    Posts
    6,242
    Rep Power
    21

    Default

    I already script deletion of zmmtaconfig.log (untill it has a logrotate/is thrown in zmlogrotate/and or put into syslog-I have no clue where that bug is anymore)
    The main cause of that file being so large -the loglevel being set too high- is fixed in 4.5.7 Bug 18445 - zmmtaconfig default loglevel is set to high

    So I should revise the script to
    Code:
    rsync -alHK
    small -l is already in -a
    Last edited by mmorse; 08-28-2007 at 01:17 PM.

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

    Default

    Quote Originally Posted by mmorse View Post
    small -l is already in -a
    Whoops, I knew that!

    What about those logfiles in /opt/zimbra/db/data?

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

    Default

    I've posted the final script to the wiki as "A Simple Shell Scripting Method" for future reference. Thanks for the suggestions, everybody!

    Dan

  9. #19
    maerten is offline Awaiting Activation
    Join Date
    Aug 2007
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by dwmtractor View Post
    ...
    Also in /opt/zimbra/db/data there are two log files ib_logfile0 and ib_logfile1 that are each about a gig in size, though I see that ib_logfile0 has today's date on it (the other is already a month old). Are these important, or also excludable from a backup?
    ...
    Do NOT exclude ib_logfile files these are part of the MySQL database! (InnoDB data)

  10. #20
    encode is offline Junior Member
    Join Date
    Oct 2007
    Posts
    9
    Rep Power
    7

    Default

    Is it necessary to stop all the zimbra services? What about just stopping ldap, MTA, and mysql? Stopping and starting spam/antivirus services seems pointless to me.

    Whats the best way to stop only selected services before doing the backup?

Page 2 of 4 FirstFirst 1234 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 07-09-2007, 11:31 PM
  2. Error message in Server status
    By Max Ma in forum Installation
    Replies: 20
    Last Post: 04-19-2007, 08:55 AM
  3. Replies: 1
    Last Post: 04-29-2006, 10:54 AM
  4. Replies: 7
    Last Post: 04-21-2006, 09:59 AM
  5. M3 problem with shares
    By titangears in forum Users
    Replies: 4
    Last Post: 01-12-2006, 01:01 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
  •