getconf method ldapsearch
getconf passwordfile
getconf binddn
+getconf ldaphost
+getconf tls yes
+
+if [ $tls = 'yes' ]; then
+ URLBASE="ldaps"
+else
+ URLBASE="ldap"
+fi
status="ok"
[ -d $backupdir ] || mkdir -p $backupdir
[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
-dbsuffixes=(`awk 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="ldbm") print db,$2}' $conf|sed -e 's/[" ]//g'`)
+dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="ldbm") print db,$2}' $conf|@SED@ -e 's/[" ]//g'`)
## LDIF DUMP
fi
if [ "$method" == "slapcat" ]; then
- if [ "$compress" == "yes" ]; then
- execstr="$SLAPCAT -f $conf -b $dbsuffix | $GZIP"
- else
- execstr="$SLAPCAT -f $conf -b $dbsuffix"
- fi
+ execstr="$SLAPCAT -f $conf -b $dbsuffix"
debug "$execstr"
else
- if [ "$compress" == "yes" ]; then
- execstr="$LDAPSEARCH -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile | $GZIP"
+ if [ -n "$ldaphost" ]; then
+ execstr="$LDAPSEARCH -H $URLBASE://$ldaphost -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile"
else
execstr="$LDAPSEARCH -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile"
fi
/etc/init.d/slapd stop
fi
- touch $dumpdir/$dbsuffix.ldif
- if [ ! -f $dumpdir/$dbsuffix.ldif ]; then
- fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif"
+ ext=
+ if [ "$compress" == "yes" ]; then
+ ext=".gz"
+ fi
+ touch $dumpdir/$dbsuffix.ldif$ext
+ if [ ! -f $dumpdir/$dbsuffix.ldif$ext ]; then
+ fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif$ext"
fi
if [ "$compress" == "yes" ]; then
- output=`$execstr > $dumpdir/$dbsuffix.ldif.gz`
+ output=`$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz`
else
output=`$execstr > $dumpdir/$dbsuffix.ldif`
fi