Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-2008, 02:03 AM
Member
 
Posts: 10
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..
Reply With Quote
  #2 (permalink)  
Old 10-05-2008, 02:17 AM
Moderator
 
Posts: 2,207
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).
Reply With Quote
  #3 (permalink)  
Old 10-05-2008, 08:50 AM
Member
 
Posts: 10
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
Reply With Quote
  #4 (permalink)  
Old 10-05-2008, 09:50 AM
Moderator
 
Posts: 6,237
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
Reply With Quote
  #5 (permalink)  
Old 10-20-2008, 02:52 AM
Active Member
 
Posts: 25
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
Reply With Quote
  #6 (permalink)  
Old 10-20-2008, 11:14 AM
Member
 
Posts: 10
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
Reply With Quote
  #7 (permalink)  
Old 10-21-2008, 01:54 PM
Active Member
 
Posts: 27
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
Reply With Quote
  #8 (permalink)  
Old 10-21-2008, 11:34 PM
Active Member
 
Posts: 25
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
Reply With Quote
  #9 (permalink)  
Old 10-22-2008, 01:04 AM
Active Member
 
Posts: 36
Default

To get list of all accounts "zmprov gaa" should work
Reply With Quote
  #10 (permalink)  
Old 02-11-2009, 12:11 PM
Junior Member
 
Posts: 8
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.