#!/bin/sh
#
# Script: enl_dump.sh
#
# This script dumps the contents of the enlighten database tables
# to flat files.
# To use this script:
# 1. It must be run by user "dbenl"
# 2. There must not be any open connections to the database; therefore, the EMD
#    should not be running. To ensure that no events data is lost, PEP
#    should not be running either. The events daemons will cache data until
#    PEP is reachable again. PEP does not cache data.
# 
# (c) 1996 ENlighten Software Solutions, Inc.
# All Rights Reserved.
#




echo "This script will dump the contents of ENlighten's Informix SE database" 
echo "tables to flat files so that the data may be imported at a later time."
echo ""
echo "Enter the full path name of a directory to hold ENlighten data"
echo "or enter q to quit:"

while true
do
	read outdir

	if [ "$outdir" = "q" -o "$outdir" = "Q" ] ; then
		exit 1
	fi

	if [ ! "$outdir" ] ; then
		echo "Enter the full path name of a directory to hold ENlighten data"
		echo "or enter q to quit:"
	elif [ ! -d "$outdir" ] ; then
		echo ""
		echo "The directory $outdir does not exist. Re-enter or"
		echo "enter q to quit:"
	else
		break
	fi
done

echo "Exporting data to $outdir/enlighten.exp..."

dbexport -c -q -o $outdir enlighten


