Results 1 to 10 of 10

Thread: [SOLVED] Individual HOT user backups - Community Version

  1. #1
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    13
    Rep Power
    7

    Default [SOLVED] Individual HOT user backups - Community Version

    I have read many posts regarding backup and restore of the OSS version and wanted to share this:

    User:SGIA - Zimbra :: Wiki

    which has worked for me in doing a hot backup of single user accounts on the open source version.

    Hope it helps someone.

    SG
    Last edited by SGIA; 10-05-2008 at 02:16 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Beaucaire, France
    Posts
    2,322
    Rep Power
    13

    Default

    Nice one.

    Why not adding what is needed for Calendar (at least the main one) and Contacts (at least the main address book) too, using the same idea ?

    The main calendar can be downloaded in ics format and uploaded the same way (using REST).

    Whoever, it might be a bit more difficult for the contacts (I don't know if there's a REST method for them).

  3. #3
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    13
    Rep Power
    7

    Default Individual HOT user backups - Community Version

    I've seen a lot of questions about Community version backups. Here's a routine I worked out, perhaps it can help someone or at least give some ideas.

    I had the problem of backing up (daily) a group of 50 users' mailboxes and taking the server down by doing a cold backup is not really an option. I am using the community version. I am not a Linux guru by any means, however was able to fashion the following scripts that function just fine for my needs, and perhaps can help someone else looking for a similar functionality. I am also up for any "professionalization" that can be done by the real Linux guys seemingly abundant in the Zimbra cosmos.

    I am using several steps here. First, a script to export a single user account using zmmailbox. This is used by the next script.
    Scripts assume the presence of a /backup/ directory and sub directory /backup/accounts. These could be variables I guess if someone wanted to make a generic version.

    Code:
     #!/bin/bash
     # baccount.sh -- Script to export select Zimbra accounts
     
     USERNAME=$1
     TODAY=`date`
     LOGFILE="/backup/log/backuplog.txt"
     
     echo $TODAY  >> $LOGFILE
     echo $USERNAME >> $LOGFILE
     /opt/zimbra/bin/zmmailbox -z -m $USERNAME gms >> $LOGFILE
     /opt/zimbra/bin/zmmailbox -z -m $USERNAME getRestURL "//?fmt=tgz" > /backup/accounts/$USERNAME.tgz
     echo --------------------- >> $LOGFILE
    The above is called using ./baccount.sh username@zimbradomain.com and outputs a file username@zimbradomain.com.tgz to the directory specified. You could use the TODAY variable to prefix the filename if you wanted unique file names (no overwrite).

    The script to put this together is as follows.

    Code:
     #!/bin/bash
     # get a list of all the accounts and create a script to 
     # execute the baccount.sh script with the email address 
     # of the user as a command line variable
     
     #use zmaccts and extract only the email address from the result
     #then concatenate the "/backup/./baccount.sh <emailaddress>" string for each account and write it to the file 
     
     /opt/zimbra/bin/./zmaccts | grep "@" | awk '{print "/backup/./baccount.sh " $1}' > /backup/accountbackup.sh
     
     # change permissions on the newly created script
     chmod 755 /backup/accountbackup.sh
     
     # Execute the newly created script - this creates a tgz file for each account
     /backup/./accountbackup.sh
      
    # this mounts an SMB drive of a neighboring win machine and copies the backups over - could be anything
    # mount -t smbfs -o username=username,password=password //windowsMachineName/windowsShare /data
    # cp /backup/accounts/*.tgz /data
    The above script queries Zimbra for a list of users and generates a shell script called /backup/accountbackup.sh,
    changes permissions on the newly created shell script and executes it, calling the baccount.sh script for each email address in the system and subsequently generating a complete mailbox export for each account.

    In my example, it then mounts a remote smb volume and copies the backups off-server.

    To restore one of these accounts, I use the command:
    Code:
     /opt/zimbra/bin/zmmailbox -z -m UserEmailAddress postRestURL "//?fmt=tgz&resolve=reset" /backup/accounts/UserEmailAddress.tgz
    I am sure this can all be made more generic and probably simplified, but I have found the flexibility of having these individual mailbox backups to be very very handy when coupled with a weekly full system backup. This procedure is run nightly.
    The restore functions best when restored to an empty, newly created account.

    Perhaps this can help someone.
    Cheers

  4. #4
    Join Date
    May 2006
    Location
    USA
    Posts
    6,242
    Rep Power
    21

    Default

    Just a quick note:
    This technique is only possible on 5.0.9+
    We also found that minor mail store corruptions like a missing blob, size mismatch, or 0 byte db entries can cause a tar operation to halt prematurely/you’ll notice missing data.

    You can determine if that is the problem by running “tar tfz account.tgz” and verifying that the listing completes without a corrupt stream error message.

    This is similar to bug 31937 (another error handling one was bug 31016) - a fix for truncating or padding mismatched blobs will be included in 5.0.10 NE & we currently plan to release an updated 5.0.10 FOSS as well.

    ZCS-to-ZCS Migrations » Zimbra :: Blog

  5. #5
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    25
    Rep Power
    7

    Default

    I have followed the instructions. When I actually perform a restore I get the following error:

    zmmailbox -z -m victoria@mydomain.com postRestURL "//?fmt=tgz&resolve=reset" /backup/accounts/victoria@mydomain.com.tgz

    ERROR: service.FAILURE (system failure: POST failed, status=409 null nullBriefcase nullCalendar nullChats nullContacts nullDrafts nullEmailed Contacts nullInbox nullJunk nullNotebook nullSent nullTasks nullTrash null)

    The email I have deleted before the restore are back in place though.

    Regards,
    Willi Eigenmann

  6. #6
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    13
    Rep Power
    7

    Default Restore

    Quote Originally Posted by weigenmann View Post
    I have followed the instructions. When I actually perform a restore I get the following error:

    zmmailbox -z -m victoria@mydomain.com postRestURL "//?fmt=tgz&resolve=reset" /backup/accounts/victoria@mydomain.com.tgz

    ERROR: service.FAILURE (system failure: POST failed, status=409 null nullBriefcase nullCalendar nullChats nullContacts nullDrafts nullEmailed Contacts nullInbox nullJunk nullNotebook nullSent nullTasks nullTrash null)

    The email I have deleted before the restore are back in place though.

    Regards,
    Willi Eigenmann
    I'm sure someone from Zimbra can answer this better, but I think it may have something to do with restoring to a mailbox that already has mails in it. Error 409 usually means that there is some kind of conflict.

    What happens if you restore to a new, empty account? Anyone from Zimbra want to offer advice?

    SG

  7. #7
    Join Date
    Nov 2007
    Posts
    27
    Rep Power
    7

    Default

    Hello,
    I Did a try with a new empty account/mailbox and got the same result as weigenman.
    Everything seams to be correct though. Mail, documents, briefcase, contact and main calendar. Really smooth solution SGIA!
    Would be nice to get som clarity about the error message though....

    Regards Mike

  8. #8
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    25
    Rep Power
    7

    Default

    Dear fellows,

    thank you for your replies. Tried again to restore to a newly created user, same error message. The restored email do show up correctly. It is working despite the error message. Nice solution to backup individual mailboxes.

    Thanks a lot.
    Regards,
    Willi

  9. #9
    Join Date
    Sep 2007
    Posts
    36
    Rep Power
    8

    Default

    To get list of all accounts "zmprov gaa" should work

  10. #10
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    6

    Default

    I found that this works to a degree - but it always stops after 5GB of mail is imported. The export from the other server is 78GB compressed (118GB or so uncompressed) and it does not carry over. Advice? No error messages... it just goes for a long time, stops, and not all the mail is there.

Similar Threads

  1. [SOLVED] Simple backup question...
    By dameron in forum Administrators
    Replies: 3
    Last Post: 08-25-2007, 09:36 PM
  2. Zimbra Install Problem - getDirectContext
    By bsimzer in forum Installation
    Replies: 27
    Last Post: 07-19-2007, 10:12 AM
  3. Getting problems in FC4 while instalation
    By kitty_bhoo in forum Installation
    Replies: 13
    Last Post: 09-12-2006, 10:34 PM
  4. Fedora Core 3, Clean Install - Not working!
    By pcjackson in forum Installation
    Replies: 17
    Last Post: 03-05-2006, 06:38 PM
  5. Network edition - strange behavior
    By goetzi in forum Installation
    Replies: 6
    Last Post: 11-16-2005, 02:08 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
  •