#!/bin/sh # # Copyright (C) 2000-2020 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, 7.2.x, 7.4.x # echo " " echo "This script will update a Bacula PostgreSQL database from version 12-15 to 16" 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 15 ] ; then echo " " echo "The existing database is version $DBVERSION !!" echo "This script can only update an existing version 12-15 database to version 16." echo "Error. Cannot upgrade this database." echo " " exit 1 fi if [ "$DBVERSION" -eq 12 ] ; then # from 5.0 if psql -f - -d ${db_name} $* <