#!/bin/sh # # Copyright (C) 2000-2015 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS # # Shell script to update PostgreSQL tables from Bacula Community version # 5.0.x, 5.2.x, 7.0.x # echo " " echo "This script will update a Bacula PostgreSQL database from version 12-14 to 15" echo " " echo "Depending on the current version of your catalog," echo "you may have to run this script multiple times." echo " " bindir=@POSTGRESQL_BINDIR@ PATH="$bindir:$PATH" db_name=@db_name@ ARGS=$* getVersion() { DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version LIMIT 1" $ARGS` } getVersion if [ "x$DBVERSION" = x ]; then echo echo "Unable to detect database version, you can specify connection information" echo "on the command line." echo "Error. Cannot upgrade this database." exit 1 fi if [ "$DBVERSION" -lt 12 -o "$DBVERSION" -gt 14 ] ; then echo " " echo "The existing database is version $DBVERSION !!" echo "This script can only update an existing version 12-14, 1014-1016 database to version 1017." echo "Error. Cannot upgrade this database." echo " " exit 1 fi if [ "$DBVERSION" -eq 12 ] ; then # from 5.0 if psql -f - -d ${db_name} $* <