SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

tdsldapbackup

Script: Bash: TDS LDAP Backup

Below you'll find a script I've used to backup TDS LDAP data which can be restored using this script into openDS or into Tivoli Directory Server with this script.

#!/bin/bash
# set -x
 
### Script Variables
WHATAMI=`basename $0`
 
### LDAP Variables
DUMPDIR=/var/backup/ldif
APPDIR=/opt/IBM/ldap/V6.0
LDAPSEARCH=/opt/IBM/ldap/V6.0/bin/ldapsearch
MANAGER=cn=manager
PASSWD=<password>
HOSTNAME=`hostname`
LDAPBASE="o=company.local"
LDAPPORT=389
 
### OLD LDAP Variables
#INSTANCE=idsldap
 
### Offsitecopy Variables
GZIP=/usr/bin/gzip
. "/opt/ITS_Tools/Scripts/mail.txt"
. "/opt/ITS_Tools/Scripts/offsitecopy.func"
TOUSER="repluser"
TOHOST="replicationserver.company.local"
TODIR="/srv/syncdata/LDAP"
LDIFFILE=${DUMPDIR}/${HOSTNAME}_${LDAPBASE}_`date +%Y%m%d%H%M`.ldif
BACKUPFILE="$LDIFFILE.gz"
LOGFILE=${DUMPDIR}/logfile_`date +%Y%m%d%H%M`.txt
DOCOPY="0"
 
usageCommand() {
   echo
   echo "Usage $0 COMMAND:"
   echo "--------------------------------------"
   echo "`tput bold``tput smul`$0 ldifbackup`tput sgr0`"
   echo "--------------------------------------"
   echo
}
 
ldifBackup() {
   echo "Creating ldif backup $LDIFFILE .. using $MANAGER"
   $LDAPSEARCH -L -D "$MANAGER" -w "$PASSWD" -h "$HOSTNAME" -p "$LDAPPORT" -b "$LDAPBASE" '(objectclass=*)' > $LDIFFILE
   $GZIP $LDIFFILE
   if [ -f $BACKUPFILE ]; then
      echo "Finished dump, output in $BACKUPFILE"
      if [ "$DOCOPY" == "1" ]; then
         offsitecopy "${BACKUPFILE}" "$TOUSER" "$TOHOST" "$TODIR" "$LOGFILE" "$WHATAMI" "$HOSTNAME" "$MAILTOSUCCESS" "$MAILTOFAIL"
      else
         echo
         echo "Copy to offsite location is not enabled."
         echo "Modify the script under Offsitecopy Variables to enable offsitecopy"
         echo
      fi
   else
      echo
      echo "$BACKUPFILE was not created."
      echo Exiting...
      echo
      exit 1
   fi
}
 
case "$1" in
 
ldifbackup )
   echo "Checking if the LDAP server is running... "
   pid=`ps -ef|grep ibmslapd|grep -v grep|awk '{ print $2 }'`
   if [ -z "$pid" ]; then
      echo
      echo "Ldap server is stopped..."
      echo "Exiting... "
      exit 1
   else
      echo "Ldap server is running..."
      ldifBackup
   fi
;;
 
* )
   usageCommand
   exit 1
;;
 
esac
 
echo
echo "INFO - LDIF backup finished"
echo

As you can see, there is an external reference to offsitecopy and mail.txt. Both are described in Script: Bash: Offsitecopy.

You could leave a comment if you were logged in.
tdsldapbackup.txt · Last modified: 2021/09/24 00:25 (external edit)