Re: ispman bdb database howto ? Wim ?

Wendelmaques <wendel-e5LGQ1J1bCxwFqzsTH5u/[email protected]> Thu, 19 May 2005 11:21:44 -0300
Newsgroups gmane.comp.isp.ispman.user
Message-ID <[email protected]>
> Once you have a working database, 
 > look at creating some backups :-)
> Because of all the problems and the 
 > inherit design problem of no audit
> trails in LDAP, I wrote a script to 
 > dump the database several times a

Hi Win, to avoid stoping openldap i'm
using the following script. and for
backend problem with OpenLDAP I'm
using 'ldbm' format.

#!/usr/local/bin/bash

# Copyright (c) 2005-2005  Wendelmaques R. Pereira.
# Terms and conditions based on the BSD copyright.
#
# /root/doc/rc.ldap-backup - general opendlap backup.
# /etc/crontab: 0 * * * * root /root/doc/rc.ldap-backup backup

# base suffix if you have multiple database
suffix="o=ispman";

# slpacat used to backup.
slapcat=/usr/local/sbin/slapcat

# slapadd use to recovery data.
slapadd=/usr/local/sbin/slapadd

# openldap configuration file.
conf=/usr/local/etc/openldap/slapd.conf

# direcoty format
date=`date "+%Y/%m/%d"`;

# base dir to store backups
basedir=/root/doc/ldap;

# function to do the backup.
function cmd_backup(){
     # protect files, to avoid unauth access.
     mkdir -p "$basedir/$date";
     chmod 700 $basedir;
     chmod 700 $basedir/$date;
     file="$basedir/$date/backup.ldif";
     mkdir -p "$basedir/$date";
     # do backup!!!
     cmd="$slapcat -f $conf -b $suffix -l $file";
     logger $cmd;
     $cmd;
}

# function to do the backup recover.
function cmd_reconver(){
     echo ": $1";
     file="$basedir/$1/backup.ldif";
     cmd="$slapadd -f $conf -b $suffix -l $file";
     logger $cmd;
     $cmd;
}

case "$1" in
  backup)
   cmd_backup $2;
  ;;
  recover)
   cmd_recover $2;
  ;;
  *)
   echo "{ backup|reconver $date }" >&2
  ;;
esac



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click