OUD Backup Script

Here is the output :


OUD Script Log Purge:: Purging the OUD Backup Script Logs older than 7 days
OUD Backup Purge:: Purging the OUD LDIF Backup older than 7 days
OUD Backup Purge:: Purging the OUD Binary Backup older than 7 days
OUD Backup:: Script Start -- 20160526_0854
Export task 20160526085425844 scheduled to start immediately
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=0 msgID=9896349 message="Export task 20160526085425844 started execution"
[26/May/2016:08:54:25 +0000] severity="INFORMATION" msgCount=1 msgID=10487422 message="Exporting to /tmp/oud-bkup/ldif/20160526_085421.ldif"
[26/May/2016:08:54:25 +0000] severity="INFORMATION" msgCount=2 msgID=8388850 message="The export will be done in Entry ID Order"
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=3 msgID=8847447 message="Exported 22 entries and skipped 0 in 0 seconds (average rate 1466.7/sec)"
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=4 msgID=9896350 message="Export task 20160526085425844 finished execution"
Export task 20160526085425844 has been successfully completed
+---  OUD LDIF Backup Verification:: Listing the backup ----+
-----
20160526_085421.ldif
-----
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend virtualAcis
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend tasks
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend schema
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend userRoot
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend replicationChanges
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944795 msg=The backup process completed successfully
+--- OUD Binary Backup Verification:: Listing the backup ----+
-----
20160526_085421
-----
OUD Backup :: Script End -- 20160526_0854
Elapsed Time ::  00h:00m:12s

OUD – Script to check replication delay



#!/bin/bash

CMD="dsreplication --advanced status --hostname localhost --port 4444 --adminUID admin --adminPasswordFile /tmp/pwd.txt --trustAll --no-prompt -b cn=oraclecontext,dc=example,dc=com --dataToDisplay missing-changes"

if [[ "$($CMD | awk /4444/'{ print $3 }')" -gt 0 ]]; then
  echo " ==  Delay in Replication == "
  echo " == Please execute the following command for detailed replication status =="
  echo "dsreplication status --hostname localhost --port 4444 --adminUID admin --adminPasswordFile ~/pwd.txt --trustAll --no-prompt"
fi

 

OUD – Monitor OUD Process

# Run the following script to monitor OUD LDAP Process Status

#!/bin/bash
LDAP_HOST=localhost
LDAP_PORT=4389
POOLING_INTERVAL=5
LOGFILE=/tmp/ldap_watchdog.log

#

echo "Watchdog started at `date`" >> $LOGFILE

while `/bin/true`; do
         ldapsearch  -h $LDAP_HOST -p $LDAP_PORT -D 'cn=directory manager' -w Welcome1 -b dc=example,dc=com -s base objectclass=* cn
        if [ $? -ne 0 ]; then
                echo "`date`: Could not establish connection to LDAP server" >> $LOGFILE
        fi
        sleep $POOLING_INTERVAL
done

OUD – Sample Ldif Script


#!/bin/ksh 

source ~/oudr2ps3.env
set -x 
 
V1=V$RANDOM 
V2=new-$V1 

ldapmodify  -h localhost -p 1389 -D "cn=directory manager" -w Welcome1 <<!
dn: cn=u0,dc=example,dc=com
changetype: modify
replace: displayName
displayName: $V1
!
 
ldapmodify   -h localhost -p 1389 -D "cn=directory manager" -w Welcome1 <<!
dn: cn=u0,dc=example,dc=com
changetype:modify
delete: displayName
displayName: $V1
-
add: displayName
displayname: $V2
!

 
sleep 2 

ldapsearch -h localhost -p 1389 -D "cn=directory manager" -w Welcome1 -b "cn=u0,dc=example,dc=com" objectclass=*  displayName 

ldapsearch -h localhost -p 1389 -D "cn=directory manager" -w Welcome1 -b "cn=u0,dc=example,dc=com" objectclass=*  displayName 

sleep 2 

ldapsearch -h localhost -p 1389 -D "cn=directory manager" -w Welcome1 -b "cn=u0,dc=example,dc=com" objectclass=*  displayName

OUD – Sample LDIF File

$ ldapmodify -a -p 1389 -D “cn=Directory Manager” -w Welcome1

dn: dc=example,dc=com
objectclass: top
objectclass: domain
dc: example

dn: ou=people,dc=example,dc=com
changetype: add
objectclass: top
objectclass: organizationalUnit
ou: people

dn: uid=ste,ou=people,dc=example,dc=com
postalAddress: Schwielowsee
postalCode: 14548
uid: ste
description: This is the description for stefan0
userPassword: password
employeeNumber: 23
initials: SW
givenName: Stefan
objectClass: person
objectClass: inetorgperson
objectClass: organizationalperson
objectClass: top
pager: +1 724 334 4454
mobile: +1 699 006 9072
cn: Stefan W
sn: W
roomNumber: 123
telephoneNumber: 456
street: Auf dem Franzensberg
homePhone: +1 698 343 6105
l: Potsdam
mail: stefan@maildomain.net
st: BR