# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1422575721 -3600 # Node ID fb742f124b205c4aa3ad41f8436ddb7c0e483bf1 # Parent c042fcdb85c9c49c775978d7d2974f78d680354d cope with file based configuration diff -r c042fcdb85c9 -r fb742f124b20 ldap-backup --- a/ldap-backup Fri Jan 30 00:44:15 2015 +0100 +++ b/ldap-backup Fri Jan 30 00:55:21 2015 +0100 @@ -9,7 +9,6 @@ ME=$(basename $0) cf=/etc/$ME.conf - if test -t 0; then # terminal/interactive destination=${1:?Need destination directory} @@ -34,13 +33,18 @@ mkdir "$dir" # save the config db -slapcat -n 0 >"$dir"/cn=config.ldif - -grep olcSuffix: "$dir"/cn=config.ldif | cut -f2 -d' ' \ - | while read suffix; do - slapcat -b "$suffix" > "$dir/$suffix.ldif" - tar czf "$destination"/"$dir".tar.gz.$$ "$dir" - mv "$destination"/"$dir".tar.gz.$$ \ - "$destination"/"$dir".tar.gz +{ + if test -d /etc/ldap/slapd.d + then + slapcat -n 0 >"$dir"/cn=config.ldif + grep olcSuffix: "$dir"/cn=config.ldif + else + ldapsearch -s base -b '' -x -LLL namingContexts | grep ^namingContexts + fi +} | cut -f2 -d' ' | while read suffix; do + slapcat -b "$suffix" > "$dir/$suffix.ldif" + tar czf "$destination"/"$dir".tar.gz.$$ "$dir" + mv "$destination"/"$dir".tar.gz.$$ \ + "$destination"/"$dir".tar.gz done