#!/bin/sh

#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright (C) 2002-2008 Mark Wong & Open Source Development Labs, Inc.
#

if [ "x${DBT2DBNAME}" = "x" ]; then
	echo "DBT2DBNAME not defined."
	exit 1
fi

while getopts "o:" opt; do
	case $opt in
	o)
		OUTPUT=$OPTARG
		;;
	esac
done

if [ "$OUTPUT" == "" ]; then
	echo "use -o and specify the backup file"
	exit 1;
fi

_test=`pg_dump ${DBT2DBNAME} --file=$OUTPUT | grep OK`
if [ "$_test" != "" ]; then
	echo "backup failed: $_test"
	exit 1
fi

exit 0
