[pkg-bacula-commits] [bacula] 03/04: improved handling of "optional" part postgresql database upgrade

Carsten Leonhardt leo at moszumanska.debian.org
Thu Jun 9 18:12:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

leo pushed a commit to branch master
in repository bacula.

commit c9db8737440534dd0bd06705f9a9b50cd62aaaef
Author: Carsten Leonhardt <leo at debian.org>
Date:   Thu Jun 9 19:52:22 2016 +0200

    improved handling of "optional" part postgresql database upgrade
---
 debian/TODO                           |  5 +++++
 debian/additions/pgsql/database/7.4.1 | 37 +++++++++++++++++++++++++++++++++++
 debian/bacula-director-pgsql.install  |  1 +
 debian/changelog                      |  2 +-
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/debian/TODO b/debian/TODO
index 3861ae3..6d85046 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -1,3 +1,8 @@
+High:
+ * add native systemd support
+   - execute config test in ExecStartPre=
+   - see https://www.freedesktop.org/software/systemd/man/systemd.service.html
+
 Normal:
 
  * Unify bacula-sd-(pgsql|mysql|sqlite3) into bacula-sd-tools, they
diff --git a/debian/additions/pgsql/database/7.4.1 b/debian/additions/pgsql/database/7.4.1
new file mode 100755
index 0000000..bb91b3f
--- /dev/null
+++ b/debian/additions/pgsql/database/7.4.1
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (c) 2016 Carsten Leonhardt
+# License: BSD 2-Clause; see file LICENSE-FOSS
+
+DBCONFIG_CONF="/etc/dbconfig-common/bacula-director-pgsql.conf"
+
+if [ -f $DBCONFIG_CONF ]; then
+	. $DBCONFIG_CONF
+else
+	echo error: $DBCONFIG_CONF does not exist - quitting
+	exit 1
+fi
+
+# prepare to securely pass the database password to psql
+export PGPASSFILE=$(mktemp)
+trap "exit_status=$?;rm -f $PGPASSFILE; exit $exit_status" INT QUIT TERM EXIT
+chmod 600 $PGPASSFILE
+chown bacula $PGPASSFILE
+cat <<EOF > $PGPASSFILE
+*:*:$dbc_dbname:$dbc_dbuser:$dbc_dbpass
+EOF
+
+# this will only pass arguments that are actually set
+ARGS="${dbc_dbname:+-d '$dbc_dbname'} ${dbc_dbserver:+-h '$dbc_dbserver'} ${dbc_dbport:+-p '$dbc_dbport'} ${dbc_dbuser:+-U '$dbc_dbuser'}"
+
+# the rest is more or less taken from upstreams
+# src/cats/update_postgresql_tables.in
+
+# For all versions, we need to create the Index on Media(PoolId/StorageId)
+# It may fail, but it's not a big problem
+su bacula -s /bin/sh -c "psql -w -f - $ARGS" <<END-OF-DATA > /dev/null
+set client_min_messages = fatal;
+CREATE INDEX media_poolid_idx on Media (PoolId);
+CREATE INDEX media_storageid_idx ON Media (StorageId);
+END-OF-DATA
diff --git a/debian/bacula-director-pgsql.install b/debian/bacula-director-pgsql.install
index b4e2b57..01e13fd 100644
--- a/debian/bacula-director-pgsql.install
+++ b/debian/bacula-director-pgsql.install
@@ -1,4 +1,5 @@
 debian/additions/pgsql/database/pgsql	usr/share/dbconfig-common/data/bacula-director-pgsql/install-dbadmin
+debian/additions/pgsql/database/7.4.1	usr/share/dbconfig-common/scripts/bacula-director-pgsql/upgrade/pgsql
 debian/additions/pgsql/make_catalog_backup_awk      etc/bacula/scripts
 etc/bacula/scripts/*catalog_backup.pl
 etc/bacula/scripts/delete_catalog_backup usr/share/bacula-common/defconfig/scripts
diff --git a/debian/changelog b/debian/changelog
index ea6e356..e6b7279 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,7 @@ bacula (7.4.1~dfsg-1) unstable; urgency=medium
   * New upstream release
   * skip old check for unsafe passwords if bacula-dir.conf doesn't
     pre-exist
-  * removed patch to fix update script for postgresql databases
+  * improved handling of "optional" part postgresql database upgrade
   * removed native systemd support pending a working solution which takes
     care not to introduce a regression of #825064 (Closes: #826163)
   * make timeout before killing bacula-sd from init script configurable,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git



More information about the pkg-bacula-commits mailing list