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

m (zim_backGetList.py)
m (zim_backGetList.py)
Line 27: Line 27:
=== zim_backGetList.py ===
=== zim_backGetList.py ===
You just have to change the line mentioning the COS (in bold)
You just have to change the lines in bold (mentioning the COS, ldap server ip and domain)
     import ldap
     import ldap

Revision as of 13:27, 23 April 2007

This is actually *Work in progress*


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


You just have to change the lines in bold (mentioning the COS, ldap server ip and domain)

   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' ]:
     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']

     l.protocol_version = ldap.VERSION3
     l.simple_bind(mapping['zimbra_ldap_userdn'], mapping['zimbra_ldap_password'])
     ldap_result_id = l.search("dc=your,dc=domain", ldap.SCOPE_SUBTREE, searchh
   Filter, retrieveAttributes)
   except ldap.LDAPError, error:
     print 'problem with ldap',error

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


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

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

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