SHIFT

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

User Tools

Site Tools


Sidebar

Sponsor:

Would you like to sponsor this site?
Or buy me a beer?:


Recently Changed Pages:

View All Pages
View All Q Pages


View All Tags


Sign up for Q to post comments.





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.


Terms And Conditions for Q users


Pages with comments

PageDateDiscussionTags
2019/06/22 10:36 1 Comment
2019/03/15 16:02 1 Comment
2019/03/15 16:02 1 Comment
2019/03/15 16:02 3 Comments
2017/04/20 15:28 1 Comment
2017/04/20 15:23 1 Comment
2017/04/19 14:44 1 Comment
2017/04/17 20:10 1 Comment
2017/04/17 20:07 1 Comment
2017/04/17 19:58 1 Comment
2017/04/17 19:52 1 Comment

View All Comments

opendsldifexport

OpenDS LDIF Export

This script will create a ldif export from a running OpenDS installation.

#!/bin/bash
# set -x
# Created by s.hooft, 22-03-2011, sjoerd_warmetal.nl

### Script Variables
WHATAMI=`basename $0`

### LDAP Variables
DUMPDIR=/var/backup/ldif
MANAGER=cn=manager
PASSWD=xxxxxxxx
HOSTNAME=`hostname`
HOSTNAME_SHORT=`hostname -s`
LDAPBASE="o=company.local"

### Offsitecopy Variables
GZIP=/usr/bin/gzip
. "/opt/scripts/mail.txt"
. "/opt/scripts/offsitecopy.func"
TOUSER="repluser"
TOHOST="syncsrv.company.local"
TODIR="/srv/syncdata/LDAP"
LDIFFILE=${DUMPDIR}/${HOSTNAME_SHORT}-LDAP_`date +%Y%m%d%H%M`.ldif
BACKUPFILE="$LDIFFILE.gz"
LOGFILE=${DUMPDIR}/ldapbackup.log
DOCOPY="1"

### Create new logfile
echo "Creating ldif backup $LDIFFILE using $MANAGER on $LDAPBASE" > $LOGFILE

mailFunction() {
   if [ "$1" == "LDIF" ]; then
      echo "LDIF backup was not created succesfully, consult $LOGFILE on ${HOSTNAME}" | mail -s "Failed $1 Backup" $MAILTOFAIL
   fi
   if [ "$1" == "GZIP" ]; then
      echo "Tar or zip was not created succesfully, consult $LOGFILE on ${HOSTNAME}" | mail -s "Failed $1 Backup" $MAILTOFAIL
   fi
   exit
}

backupFunction () {
   /opt/OpenDS-2.2.0/bin/export-ldif --bindDN "$MANAGER" --bindPassword "$PASSWD" --backendID userRoot --trustAll --excludeAttribute entryUUID --ldifFile $LDIFFILE >> $LOGFILE
   LDIFRESULT=$?
   if [ ! "$LDIFRESULT" == "0" ]; then
      mailFunction LDIF
   fi
   $GZIP $LDIFFILE >> $LOGFILE
   GZIPRESULT=$?
   if [ ! "$GZIPRESULT" == "0" ]; then
      mailFunction GZIP
   fi
   copyFunction
}

copyFunction() {
   if [ "$DOCOPY" == "1" ]; then
      offsitecopy "${BACKUPFILE}" "$TOUSER" "$TOHOST" "$TODIR" "$LOGFILE" "$WHATAMI" "$HOSTNAME" "$MAILTOSUCCESS" "$MAILTOFAIL"
   else
      echo >> $LOGFILE
      echo "Copy to offsite location is not enabled." >> $LOGFILE
      echo "Modify the script under Offsitecopy Variables to enable offsitecopy" >> $LOGFILE
      echo >> $LOGFILE
   fi
}

backupFunction

exit

The offsitecopy.func and mail.txt can be found here.

You could leave a comment if you were logged in.
opendsldifexport.txt · Last modified: 2013/04/30 15:12 by sjoerd