Bug #2680

Backup config: can't restore LDAP dump

Added by Giacomo Sanchietti over 7 years ago. Updated over 7 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-directory
Target version:v6.5-final
Security class: Resolution:
Affected version:v6.5-rc1 NEEDINFO:No

Description

When restoring a configuration backup, LDAP dump will not be restored because the action nethserver-directory-restore-ldap will fail in post-restore-config event.

The action can't load the new dump because slapd is still running. The action must use upstart interface instead of the old service command.

Workaround
Stop LDAP then execute the restore:

stop slapd
restore-config
start slapd

Proposed patch:

--- /etc/e-smith/events/post-restore-config/S20nethserver-directory-restore-ldap.ori    2014-02-28 15:46:56.321985102 +0100
+++ /etc/e-smith/events/post-restore-config/S20nethserver-directory-restore-ldap    2014-02-28 15:47:21.819047104 +0100
@@ -1,9 +1,10 @@
 #!/bin/bash

-/sbin/service slapd stop
+stop slapd
 /bin/find /var/lib/ldap/ -name \*.bdb -exec rm -f '{}' \;
 rm -rf /etc/openldap/slapd.d/
 mkdir -p /etc/openldap/slapd.d/
 /usr/sbin/slapadd -F /etc/openldap/slapd.d -n 0 -l /var/lib/nethserver/backup/ldap-config.ldif
 chown -R ldap:ldap /etc/openldap/slapd.d
 /bin/su - ldap -s /bin/bash -c "/usr/sbin/slapadd -F /etc/openldap/slapd.d -n 2 -l /var/lib/nethserver/backup/ldap-data.ldif" 
+start slapd


Related issues

Related to NethServer 6 - Feature #2014: Service supervision with Upstart CLOSED 11/15/2013 11/15/2013

Associated revisions

Revision 4c21396e
Added by Giacomo Sanchietti over 7 years ago

Restore config: use upstart for slapd. Refs #2680

History

#1 Updated by Giacomo Sanchietti over 7 years ago

  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20

#2 Updated by Giacomo Sanchietti over 7 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Giacomo Sanchietti
  • % Done changed from 20 to 30

#3 Updated by Giacomo Sanchietti over 7 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60

#4 Updated by Giacomo Sanchietti over 7 years ago

  • Status changed from MODIFIED to ON_QA
  • Assignee deleted (Giacomo Sanchietti)
  • % Done changed from 60 to 70
Package in nethserver-testing:
  • nethserver-directory-2.0.1-1.0git4c21396e.ns6.noarch.rpm

Test case

  • Execute the backup:
    backup-config
    
  • Delete the admin user from LDAP tree:
    echo -e "dn: uid=admin,ou=People,dc=directory,dc=nh\nchangetype: delete\n" > test-ldif
    ldapmodify  -Y EXTERNAL -f test-ldif
    
  • Restore the config:
    restore-config
    
  • Check if deleted entry has been restored:
    ldapsearch -Y EXTERNAL -b ou=People,dc=directory,dc=nh '(uid=admin)'
    

#5 Updated by Davide Principi over 7 years ago

  • Assignee set to Davide Principi

#6 Updated by Davide Principi over 7 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (Davide Principi)
  • % Done changed from 70 to 90

VERIFIED

Implementation note: next time, use the NethServer::Service perl module, that abstracts the underlying service manager:

$slapd = NethServer::Service->new('slapd');

$slapd->stop();
# execute slapcat
$slapd->start();

More info: perldoc NethServer::Service

#7 Updated by Davide Principi over 7 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100

In nethserver-updates:
nethserver-directory-2.0.2-1.ns6.noarch.rpm

Also available in: Atom PDF