Difference between revisions of "Per User Mailbox Backup (OE Version)"

m (zim_backGetList.py)
m (zim_backGetList.py)
Line 59: Line 59:
 
   
 
   
 
     try:
 
     try:
       l=ldap.open('192.168.5.33')
+
       l=ldap.open(''''ldap-server-ip'''')
 
       l.protocol_version = ldap.VERSION3
 
       l.protocol_version = ldap.VERSION3
 
       l.simple_bind(mapping['zimbra_ldap_userdn'], mapping['zimbra_ldap_password'])
 
       l.simple_bind(mapping['zimbra_ldap_userdn'], mapping['zimbra_ldap_password'])

Revision as of 13:26, 23 April 2007

This is actually *Work in progress*

Scope

This is a solution to backup mails on a user basis for the Open Source Version. It will permit to restore a mailstore for a particular user without having to restore the full /opt/zimbra directory.

It is based on a cold backup method.

Method used

- User concerned by this backup have a a specific C.O.S.
- first script connects to ldap server and builds the list of concerned users
- second script loops on the user list and creates a specific sql file with the appropriate commands for a restore

How to use it

This is how I plan to use it :

  • stop zimbra
  • take lvm snapshot
  • start ldap & mysql services
  • run the specific scripts for user backup
  • start zimbra completely
  • run the backup as usual
  • close the snapshot

The scripts

zim_backGetList.py

You just have to change the line mentioning the COS (in bold)

   #!/usr/bin/python
   import ldap
   import re
   import MySQLdb
   import exceptions
   import xml.dom.minidom
   import os
   from xml.dom.minidom import Node

   # scan de la configuration de zimbra
   doc = xml.dom.minidom.parse("/opt/zimbra/conf/localconfig.xml")
   mapping = {}

   for node in doc.getElementsByTagName("key"):
     key = node.getAttribute("name")
     if key not in [ 'zimbra_ldap_userdn', 'zimbra_ldap_password', 'mysql_root_passs
   word' ]:
       continue
     L = node.getElementsByTagName("value")
     for node2 in L:
       title = ""
       for node3 in node2.childNodes:
         if node3.nodeType == Node.TEXT_NODE:
           title += node3.data
       mapping[key] = title

   # recuperation des account_id ayant la COS avec suffixe .backup
   searchFilter = "(zimbraCOSId=67890ffa-ef21-4d27-a79d-e49da536fc13)"
   retrieveAttributes = ['zimbraId', 'uid']

   try:
     l=ldap.open('ldap-server-ip')
     l.protocol_version = ldap.VERSION3
     l.simple_bind(mapping['zimbra_ldap_userdn'], mapping['zimbra_ldap_password'])
     ldap_result_id = l.search("dc=paris,dc=iufm,dc=fr", ldap.SCOPE_SUBTREE, searchh
   Filter, retrieveAttributes)
   except ldap.LDAPError, error:
     l.unbind()
     print 'problem with ldap',error

   user_ids = []
   while 1:
     result_type, result_data = l.result(ldap_result_id, 0)
     if (result_data == []):
       break
     else:
       if result_type == ldap.RES_SEARCH_ENTRY:
         user_ids.append( result_data[0][1]['zimbraId'][0] )

   l.unbind()

   userlist = open("/tmp/userlist.txt", "w")

   for user in user_ids:
     userlist.write( user + "\n")
   userlist.close()

   os.system('/usr/local/sbin/zim_DoBackup.sh ' + mapping['mysql_root_password'])
Jump to: navigation, search