Hi,
> May I assume that only the addition of -m is relevant, and that the
> other changes are unrelated?
No, I just found out that -m $xyz is irrelevant.
> I'm curious what exact environment variable(s) we need, that requires
> adding -m for *this* specific command.
I just tried it out - again, the current code on my system will be
expanded to this command:
su - postgres -c 'psql -AtU postgres -c "SELECT datname FROM pg_database
WHERE NOT datistemplate"'
Which will lead to this output:
root@degserv /usr/share/backupninja # su - postgres -c 'psql -AtU
postgres -c "SELECT datname FROM pg_database WHERE NOT datistemplate"'
-su: 29: /usr/share/bash-completion/bash_completion: [[: not found
-su: 35: /usr/share/bash-completion/bash_completion: [[: not found
-su: 51: /usr/share/bash-completion/bash_completion: shopt: not found
-su: 57: /usr/share/bash-completion/bash_completion: complete: not found
-su: 62: /usr/share/bash-completion/bash_completion: complete: not found
-su: 65: /usr/share/bash-completion/bash_completion: complete: not found
-su: 68: /usr/share/bash-completion/bash_completion: complete: not found
-su: 71: /usr/share/bash-completion/bash_completion: complete: not found
-su: 74: /usr/share/bash-completion/bash_completion: complete: not found
-su: 77: /usr/share/bash-completion/bash_completion: complete: not found
-su: 80: /usr/share/bash-completion/bash_completion: complete: not found
-su: 83: /usr/share/bash-completion/bash_completion: complete: not found
-su: 86: /usr/share/bash-completion/bash_completion: complete: not found
-su: 89: /usr/share/bash-completion/bash_completion: complete: not found
-su: 92: /usr/share/bash-completion/bash_completion: complete: not found
-su: 101: /usr/share/bash-completion/bash_completion: Syntax error: "("
unexpected (expecting "}")
But my fix leads to this command (I removed -m xyz):
su -c 'psql -AtU postgres -c "SELECT datname FROM pg_database WHERE NOT
datistemplate"'
And this will list the name of the databases.
I removed the -m and attached a patch for /usr/share/backupninja/pgsql
which also fixes the broken debug command.
> But regardless, I'll merge the patch upstream once someone else than
> the patch submitter has tested it. To increase chances that this
> happens, I would suggest posting the patch on an issue upstream:
>
> https://0xacab.org/backupninja/backupninja/
>
> … and possibly asking for testers on the upstream mailing list.
Sorry, but: Could you do this for me? I'm not really familiar with these
kind of things.
Alles Gute,
Christof Thalhofer
--
--- pgsql 2016-07-14 12:36:12.000000000 +0200
+++ pgsql.new 2016-07-14 12:38:39.601526817 +0200
@@ -97,8 +97,9 @@
if [ "$usevserver" = "yes" ]; then
cmdprefix="$VSERVER $vsname exec "
fi
- execstr="${cmdprefix} su - $PGSQLUSER -c 'psql -AtU $PGSQLUSER -c \"SELECT datname FROM pg_database WHERE NOT datistemplate\"'"
- debug execstr
+ # fix for Bug#824508: backupninja: Postgresql 9.4 backup databases = all crashes
+ execstr="${cmdprefix} su -c 'psql -AtU $PGSQLUSER -c \"SELECT datname FROM pg_database WHERE NOT datistemplate\"'"
+ debug "$execstr"
dblist=""
for db in $(eval $execstr 2>&1); do
dblist="$dblist $db"