barcus/bareos

New Installation: false DB Encoding

Closed this issue · 3 comments

Hello,

I get a warning in bconsole on a new installation:
Warning: Encoding error for database "bareos". Wanted SQL_ASCII, got UTF8
I think the encoding of DB ist false. Steps to replicate:

psql -U bareos
\l
   Name    | Owner  | Encoding |  Collate   |   Ctype    | Access privileges
-----------+--------+----------+------------+------------+-------------------
 bareos    | bareos | UTF8     | en_US.utf8 | en_US.utf8 

On my old installation it shows:

   Name    |  Owner   | Encoding  |  Collate   |   Ctype    |   Access privileges
-----------+----------+-----------+------------+------------+-----------------------
 bareos    | postgres | SQL_ASCII | C          | C       

and i don't have any warnings.

OS: Debian 10.10
Docker version 20.10.7
Docker-compose version 1.29.2
Ubuntu 20 latest with Postgres

Can you take a look please.
Best regards
Johann

Temporary solution - change encoding to SQL_ASCII
dc = docker-compose

# stop containers
cd /opt/bareos/
dc stop bareos-dir
dc stop bareos-fd
dc stop bareos-sd
dc stop bareos-webui

dcexec bareos-db env
dcexec bareos-db bash

# install sudo
apt-get update
apt-get install sudo
sudo -u postgres bash

# create dump
pg_dump -U bareos bareos > /tmp/bareos_dump.sql

# create new Role
CREATE USER postgres WITH SUPERUSER PASSWORD 'strong-password';
ALTER USER postgres WITH CREATEDB CREATEROLE CREATEUSER REPLICATION;

# Delete DB bareos
dropdb -U postgres bareos
psql -U postgres

UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1;
VACUUM FREEZE;
\q

# create DB bareos with Encoding SQL_ASCII
createdb -U postgres -E SQL_ASCII bareos
psql -U postgres bareos < /tmp/bareos_dump.sql
psql -U postgres
\l
\q

Best regards
Johann

Thank you very much for your feeback
As you said it seems to be related to default database template in PG which is loaded with UTF-8 encoding.
I'm gonna fix it inside PG docker image directly.

i don't find more simple, using this environment variable in docker-compose file

environment: - POSTGRES_INITDB_ARGS=--encoding=SQL_ASCII