Univention Bugzilla – Attachment 5878 Details for
Bug 32685
Move & selective replication
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix creating backup
32685_replication-backup.diff (text/plain), 3.02 KB, created by
Philipp Hahn
on 2014-04-16 19:37 CEST
(
hide
)
Description:
Fix creating backup
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2014-04-16 19:37 CEST
Size:
3.02 KB
patch
obsolete
>diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-replication/replication.py b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-replication/replication.py >index ae906e0..aa4d466 100644 >--- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-replication/replication.py >+++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-replication/replication.py >@@ -808,35 +808,34 @@ def flatmode_reconnect(): > def _delete_dn_recursive(l, dn): > try: > l.delete_s(dn) >- except ldap.NOT_ALLOWED_ON_NONLEAF, msg: >+ except ldap.NOT_ALLOWED_ON_NONLEAF: > univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, 'Failed to delete non leaf object: dn=[%s];' % dn) >- dns=[] >- for dn,attr in l.search_s(dn, ldap.SCOPE_SUBTREE, '(objectClass=*)'): >- dns.append(dn) >+ dns = [dn_ for dn_, _attr in l.search_s(dn, ldap.SCOPE_SUBTREE, '(objectClass=*)', attrlist=['dn'])] > dns.reverse() > for dn in dns: > l.delete_s(dn) >- except ldap.NO_SUCH_OBJECT, msg: >+ except ldap.NO_SUCH_OBJECT: > pass > > def _backup_dn_recursive(l, dn): >+ try: >+ result = l.search_s(dn, ldap.SCOPE_SUBTREE, '(objectClass=*)', attrlist=['*', '+']) >+ except ldap.NO_SUCH_OBJECT: >+ return >+ > backup_directory = '/var/univention-backup/replication' > if not os.path.exists(backup_directory): > os.makedirs(backup_directory) > os.chmod(backup_directory, 0700) >- >+ > backup_file = os.path.join(backup_directory, str(time.time())) >- fd = open(backup_file, 'w+') >- fd.close() >- os.chmod(backup_file, 0600) > univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS, 'replication: dump %s to %s' % (dn, backup_file)) >- >- fd = open(backup_file, 'w+') >- ldif_writer = ldifparser.LDIFWriter(fd) >- for dn,entry in l.search_s(dn, ldap.SCOPE_SUBTREE, '(objectClass=*)', attrlist=['*', '+']): >- ldif_writer.unparse(dn,entry) >- fd.close() >- >+ os.chmod(backup_file, 0600) >+ with open(backup_file, 'w+') as fd: >+ ldif_writer = ldifparser.LDIFWriter(fd) >+ for dn, entry in result: >+ ldif_writer.unparse(dn,entry) >+ > def _get_current_modrdn_link(): > return os.path.join(STATE_DIR, 'current_modrdn') > >@@ -1024,7 +1023,6 @@ def handler(dn, new, listener_old, operation): > univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS, 'replication: the current modrdn points to a different entryUUID: %s' % os.readlink(current_modrdn_link)) > > old_dn = _read_dn_from_file(current_modrdn_link) >- > if old_dn: > univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS, 'replication: the DN %s from the current_modrdn_link has to be backuped and removed' % (old_dn)) > try: >@@ -1033,9 +1031,11 @@ def handler(dn, new, listener_old, operation): > # The backup will fail in LDIF mode > pass > _delete_dn_recursive(l, old_dn) >+ if dn == old_dn: >+ old = None > else: > univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, 'replication: no old dn has been found') >- >+ > if not old: > _add_object_from_new(l, dn, new) > elif old:
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 32685
:
5877
| 5878