备份: cat ldap_backup.sh
#!/bin/bash
/usr/sbin/slapcat >/S3/openldap/openldap_backup_`date -d "-1 day" +%Y%m%d`.ldif
[ $? -ne 0 ]&& echo "$time $host backup failed!" |mail -s "Openldap Backup Problem " xxxxx@xxxxx.com
恢复:
#清空openldap
ldapdelete -x -w 'password' -D'cn=Manager,dc=ldap,dc=xxxxx,dc=net' -r 'dc=ldap,dc=xxxxx,dc=net'
#停止openldap服务
/etc/init.d/slapd stop
#导入数据,启动服务
slapadd -l backup.ldif
chown -R ldap.ldap /var/lib/ldap /etc/openldap
/etc/init.d/slapd start