Offsite LDAP server setup

To configure your offsite running LDAP server, you should have below prerequisites.
- Both Master and slave server running with the same slapd.conf file.
- Password less authentication configured to log in from Master server to slave server.

Slave server's IP address: 192.168.19.20

Run below shell script on Master server.

#!/bin/sh

#Below command will export from Master server
/usr/sbin/slapcat -f /etc/openldap/slapd.conf > /ldapbackup/ldap-` date +%d-%m-%Y`.ldif

###############Backup Restoration on LDAP Backup/slave server#########################

#Below command will stop LDAP service on Slave server
ssh root@192.168.19.20 "/etc/init.d/ldap stop"

#This command will remove LDAP schema directory from the server
ssh root@192.168.19.20 "rm -rf /var/lib/ldap/domain.com/"

#This command will create schema directory on Slave server
ssh root@192.168.19.20 "mkdir -p /var/lib/ldap/domain.com/"

#This command will set ldap as owner of Schema directory
ssh root@192.168.19.20 "chown -R ldap.ldap /var/lib/ldap/domain.com/"

#This command will copy backup from Master server to Slave server on /root/ldapback_letest.ldif location
scp /ldapbackup/ldap-` date +%d-%m-%Y`.ldif root@192.168.19.20:/root/ldapback_letest.ldif

#This command will start LDAP service on Slave server
ssh root@192.168.19.20 "/etc/init.d/ldap start"

#This command will stop LDAP service on Slave server
ssh root@192.168.19.20 "/etc/init.d/ldap stop"

#This command will restore LDAP backfile on Slave server
ssh root@192.168.19.20 "slapadd -v -c -l /root/ldapback_letest.ldif -f /etc/openldap/slapd.conf"

#This command will start LDAP on Slave server
ssh root@192.168.19.20 "/etc/init.d/ldap start"

No comments:

Post a Comment