#1108272 bacula-director-pgsql: update_postgresql_tables script fails due to bad shell quoting

#1108272#5
Date:
2025-06-24 16:18:47 UTC
From:
To:
Hi,

I installed the bacula director from backports, so that my laptop (which
runs unstable) can still be backed up to my server (which runs stable).

After the upgrade to bacula 15, I noticed that my director was no longer
running. Checking the logs, I found the following:

24-jun 18:00 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 1026, got 1024
24-jun 18:00 bacula-dir JobId 0: Fatal error: Could not open Catalog "MyCatalog", database "bacula".
24-jun 18:00 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 1026, got 1024
24-jun 18:00 bacula-dir ERROR TERMINATION

This surprised me, because obviously there's a script to handle this. So
I ran it manually, and received errors about SQL syntax where it said
"do <number>".

Checking the script, I quickly found the problem. Here's a patch that
solved it for me:
--- update_postgresql_tables.orig	2025-06-24 18:14:43.055571381 +0200
+++ update_postgresql_tables	2025-06-24 18:15:04.866426330 +0200
@@ -642,7 +642,7 @@

#1108272#10
Date:
2025-06-26 05:03:38 UTC
From:
To:
Interesting that the Upgrade Script via dbconfig did not run. Have you
configured the bacula packages to not use dbconfig? Or has some sequence
caused it to fail?

Could you check apts history or term logs to check of anything related
to the upgrade?

That is upstreams script that is not used directly by the packages,
which use an extracted version via dbconfig, so that bug will not
directly affect users using the Debian-way-of-things to maintain the
database.

I can see the correct quotation of $$ in the source for that script, but
this seems to get mangled during build.

Grüße,
Sven.

#1108272#15
Date:
2025-06-26 12:48:31 UTC
From:
To:
Hi Sven,

So debconf-show bacula-director-pgsql shows me this, amongst others:

* bacula-director-pgsql/dbconfig-upgrade: false

Which indicates that perhaps, somehow, it is indeed disabled. This is
not what I wanted.

I don't remember manually setting this option. When I run
"dpkg-reconfigure -plow bacula-director-pgsql" to correct it, it asks me
if I want to *reinstall* the database (which I read as "throw away
everything in your catalog away and start from scratch", which is a hard
"no"), but does not ask me the question about upgrading.

This feels wrong on so many levels. I'm not sure whether this is decided
in dbconfig-common or in bacula, but if the latter, please fix that :-)

Given the above, I doubt it matters anymore, but regardless, the output
of "grep bacula /var/lib/dpkg.log" on the machine follows. Note that it
mentions "13.0.4-1", as I initially upgraded to the unstable version
before there was a version in backports. I don't know whether this is
relevant or not.

2025-06-22 15:29:27 upgrade bacula-director:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:27 status half-configured bacula-director:amd64 13.0.4-1
2025-06-22 15:29:27 status unpacked bacula-director:amd64 13.0.4-1
2025-06-22 15:29:27 status half-installed bacula-director:amd64 13.0.4-1
2025-06-22 15:29:27 status unpacked bacula-director:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:28 upgrade bacula-director-pgsql:all 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:28 status half-configured bacula-director-pgsql:all 13.0.4-1
2025-06-22 15:29:28 status unpacked bacula-director-pgsql:all 13.0.4-1
2025-06-22 15:29:28 status half-installed bacula-director-pgsql:all 13.0.4-1
2025-06-22 15:29:29 status unpacked bacula-director-pgsql:all 15.0.3-1~bpo12+1
2025-06-22 15:29:29 upgrade bacula-bscan:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:29 status half-configured bacula-bscan:amd64 13.0.4-1
2025-06-22 15:29:29 status unpacked bacula-bscan:amd64 13.0.4-1
2025-06-22 15:29:29 status half-installed bacula-bscan:amd64 13.0.4-1
2025-06-22 15:29:29 status unpacked bacula-bscan:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:29 upgrade bacula-common-pgsql:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:29 status half-configured bacula-common-pgsql:amd64 13.0.4-1
2025-06-22 15:29:29 status unpacked bacula-common-pgsql:amd64 13.0.4-1
2025-06-22 15:29:29 status half-installed bacula-common-pgsql:amd64 13.0.4-1
2025-06-22 15:29:29 status unpacked bacula-common-pgsql:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:29 upgrade bacula-sd:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:29 status half-configured bacula-sd:amd64 13.0.4-1
2025-06-22 15:29:30 status unpacked bacula-sd:amd64 13.0.4-1
2025-06-22 15:29:30 status half-installed bacula-sd:amd64 13.0.4-1
2025-06-22 15:29:30 status unpacked bacula-sd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:30 upgrade bacula-tray-monitor:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:30 status half-configured bacula-tray-monitor:amd64 13.0.4-1
2025-06-22 15:29:30 status unpacked bacula-tray-monitor:amd64 13.0.4-1
2025-06-22 15:29:30 status half-installed bacula-tray-monitor:amd64 13.0.4-1
2025-06-22 15:29:30 status unpacked bacula-tray-monitor:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:31 upgrade bacula-fd:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:31 status half-configured bacula-fd:amd64 13.0.4-1
2025-06-22 15:29:31 status unpacked bacula-fd:amd64 13.0.4-1
2025-06-22 15:29:31 status half-installed bacula-fd:amd64 13.0.4-1
2025-06-22 15:29:31 status unpacked bacula-fd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:31 upgrade bacula-console-qt:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:31 status half-configured bacula-console-qt:amd64 13.0.4-1
2025-06-22 15:29:31 status unpacked bacula-console-qt:amd64 13.0.4-1
2025-06-22 15:29:31 status half-installed bacula-console-qt:amd64 13.0.4-1
2025-06-22 15:29:31 status unpacked bacula-console-qt:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:31 upgrade bacula-console:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:31 status half-configured bacula-console:amd64 13.0.4-1
2025-06-22 15:29:32 status unpacked bacula-console:amd64 13.0.4-1
2025-06-22 15:29:32 status half-installed bacula-console:amd64 13.0.4-1
2025-06-22 15:29:32 status unpacked bacula-console:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:32 upgrade bacula-common:amd64 13.0.4-1 15.0.3-1~bpo12+1
2025-06-22 15:29:32 status half-configured bacula-common:amd64 13.0.4-1
2025-06-22 15:29:32 status unpacked bacula-common:amd64 13.0.4-1
2025-06-22 15:29:32 status half-installed bacula-common:amd64 13.0.4-1
2025-06-22 15:29:33 status unpacked bacula-common:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:33 configure bacula-common:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:33 status unpacked bacula-common:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:33 status half-configured bacula-common:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:34 status installed bacula-common:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:34 configure bacula-sd:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:34 status unpacked bacula-sd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:34 status half-configured bacula-sd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:41 status installed bacula-sd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:41 configure bacula-console-qt:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:41 status unpacked bacula-console-qt:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:41 status half-configured bacula-console-qt:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 status installed bacula-console-qt:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 configure bacula-console:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:42 status unpacked bacula-console:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 status half-configured bacula-console:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 status installed bacula-console:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 configure bacula-fd:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:42 status unpacked bacula-fd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:42 status half-configured bacula-fd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status installed bacula-fd:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 configure bacula-tray-monitor:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:44 status unpacked bacula-tray-monitor:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status half-configured bacula-tray-monitor:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status installed bacula-tray-monitor:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 configure bacula-common-pgsql:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:44 status unpacked bacula-common-pgsql:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status half-configured bacula-common-pgsql:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status installed bacula-common-pgsql:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 configure bacula-bscan:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:44 status unpacked bacula-bscan:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status half-configured bacula-bscan:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 status installed bacula-bscan:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:44 configure bacula-director-pgsql:all 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:44 status unpacked bacula-director-pgsql:all 15.0.3-1~bpo12+1
2025-06-22 15:29:45 status half-configured bacula-director-pgsql:all 15.0.3-1~bpo12+1
2025-06-22 15:29:46 status installed bacula-director-pgsql:all 15.0.3-1~bpo12+1
2025-06-22 15:29:46 configure bacula-director:amd64 15.0.3-1~bpo12+1 <none>
2025-06-22 15:29:46 status unpacked bacula-director:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:46 status half-configured bacula-director:amd64 15.0.3-1~bpo12+1
2025-06-22 15:29:48 status installed bacula-director:amd64 15.0.3-1~bpo12+1

#1108272#20
Date:
2025-06-28 20:12:06 UTC
From:
To:
Hi Wouter,

Wouter Verhelst <w@uter.be> writes:

I'd recommend that you use an editor to set

dbc_upgrade='true'

in /etc/dbconfig-common/bacula-director-pgsql.conf. That will make
future upgrades work.

In the debconf information included in the original bug report the
corresponding line starts with an '*'. That probably means that it
was set to deviate from the default via debconf. How that happened is a
question that will be hard to answer. Which version of bacula did you
start your deployment with originally?

Groetjes,

Carsten

#1108272#25
Date:
2025-06-30 13:35:52 UTC
From:
To:
Sven Hartge <sven@svenhartge.de> writes:

I wonder if I should rework the database stuff so that it will
shell-unquote during the extraction process and not patch the upstream
scripts, so that people can still use them as-is if they want. I think
that would be better overall.

(Some time later)

I've implemented it and it seems much more elegant - just a call to sed
instead of a patch that needs manual attention when things change. When
I have time I'll do a binary comparison of the resulting packages.

It's in the branch unescape-shell-quoting.

 - Carsten

#1108272#30
Date:
2025-07-22 07:32:35 UTC
From:
To:
This bug does not fit the severity "important" as it does not have "a
major effect on the usability" of the package.

#1108272#37
Date:
2025-07-28 11:56:05 UTC
From:
To:
Carsten Leonhardt <leo@debian.org> writes:

When we apply this, it also addresses Ubuntu bug 1882032.

#1108272#42
Date:
2025-08-17 13:34:11 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
bacula, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1108272@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Carsten Leonhardt <leo@debian.org> (supplier of updated bacula package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 13 Aug 2025 10:10:27 +0200
Source: bacula
Architecture: source
Version: 15.0.3-4
Distribution: unstable
Urgency: medium
Maintainer: Debian Bacula Team <pkg-bacula-devel@lists.alioth.debian.org>
Changed-By: Carsten Leonhardt <leo@debian.org>
Closes: 1108272 1109499 1109565
Changes:
 bacula (15.0.3-4) unstable; urgency=medium
 .
   [ Sven Hartge ]
   * Add support for ZSTD compression.
   * Pull 8d9669fb2 from Upstream git to fix libzstd detection
   * Flip debconf question about DB upgrade space to default to true
     (Closes: #1109499)
 .
   [ Carsten Leonhardt ]
   * Rework handling of database upgrade scripts in regard to shell quoting
     (Closes: #1108272)
   * Show a message when the user decides to abort the upgrade (Closes: #1109565)
 .
   [ Jonas Jelten ]
   * use UTF8 encoding for new postgresql databases
Checksums-Sha1:
 5edef5188f61fb390a07e06a18f9b154c3020568 3732 bacula_15.0.3-4.dsc
 bff0c996e1035c31d590382b5b2afb2c1d99aaa6 102484 bacula_15.0.3-4.debian.tar.xz
Checksums-Sha256:
 e1b0cdc59fd6768cfc48696c6d5a565a2f9f4c28e3b76ec81b637a25ebbc1f85 3732 bacula_15.0.3-4.dsc
 925a6c18821361ed0c989ccf28e4f02b40704351c1e9809d06b45c2368e06a6f 102484 bacula_15.0.3-4.debian.tar.xz
Files:
 4ec4ee913f68bc52c4b72c7861089e98 3732 admin optional bacula_15.0.3-4.dsc
 10ddea852331ed2fe65514601d1a26a7 102484 admin optional bacula_15.0.3-4.debian.tar.xz
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEETxO/995XSygF6EUmKrIctfbulV4FAmih13APHGxlb0BkZWJp
YW4ub3JnAAoJECqyHLX27pVekhsP/3KmhIpKXUrHku2yv/40a7Mei5fVJnU4E5Wn
9hqoCLi7YWHRwt97bZ8Qquh/QJm04L1rZfnBeCY4mSi6vLqeykLGP+zhv/IPTr5N
g8NJn4pVM6kruOhrKOSDx0DaLLf3/77sbkI2Tpe8VFulhVNK5v8/F1Hw2kMFumtv
gv+Liz7GVkYQgl6Rlkzn8uGiiES++RYYj/aaZPt1qbEjxAIbmhK4uW7PMbb6cOmF
4DLClUJJcCtdg7NCOvHsWAcQZEXpln+3Kx/FDIBGpvRHETKOoiudpgohdrBYdQGy
sLKbClHIwjBq9s0xwjNr9nzRebEhMIH+/2Kgx1Py9sCi3dl2qiFT2e8Ozc5ttUGX
l3HdFi+hXB1B6fP18+4++lQcFCAxL1xDC4SlYmPIaB5DaKX3d78k8UB1+iqvlHaa
5j5amwlGPPtkH7zdVMhA+yokJP36yN7RQW6d1cSsDR+qchr5j415dbqb/TF7gGil
tgm6zbTilPUjR+8hSVZa+xNHX09sNlsXySklde9US8567zIzo5auAqRVSKWn6mTm
c10WlRnlnLjsbaZMb8aXq8HkwKWIExY8sweWMhjwAx0rNNUZm0dLV7WgFXHrhpM1
6wulJ1CJoi3USojbWh3ozgekqvoOIvkEY5z3knC14DfgSPqLsTNAMomi8VvBnH0P
nfk35dGk
=qSl1
-----END PGP SIGNATURE-----