Hi,
I was able to solve the problems.
Here is a brief description of what I did, which may help someone else in the future:
Since the non-migrated server and database were working:
On the old server:
----------------------------
- MAKE A BACKUP OF THE DATABASE.
- CLEAN UP THE DATABASE:
/usr/sbin/bareos-dbcheck -u bareos -d bareos -f (wait .....)
- LOG INTO THE DATABASE AND CLEAN UP
VACUUM VERBOSE ANALYZE file;
- EXTRACT THE DATABASE SCHEMA:
postgres=# \! pg_dump --schema-only --username=postgres --dbname=bareos > /<path>/schema_only.sql
On the new server:
------------------------------
- INSTALL THE OLD POSTGRES VERSION - IF YOU NEED IT TEMPORARLY
- INSTALL THE NEW POSTGRES VERSION
- CREATE THE NEW DB
sudo pg_createcluster 16 main --datadir=/your-path/database
- ADJUST PORT IF NECESSARY:
vi /etc/postgresql/16/main/postgresql.conf
port = 5432
- START THE DB, CREATE USER AND TABLESPACE:
sudo -u postgres psql -p 5432 -c “CREATE ROLE bareos LOGIN;”
sudo -u postgres psql -c “CREATE TABLESPACE bareos_ts LOCATION ‘/your-path/database’;”
- SET THE CORRECT ENCODING:
sudo -u postgres createdb bareos \
-O bareos \
-E SQL_ASCII \
-T template0 \
--lc-collate=C \
--lc-ctype=C
- CHECK ENCODING:
sudo -u postgres psql -c “\l bareos”
Example Output:
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
--------+--------+-----------+-----------------+---------+-------+------------+-----------+-------------------
bareos | bareos | SQL_ASCII | libc | C | C | | |
(1 row)
- CREATE BAREOS USER, SET PASSWORD:
sudo -u postgres psql -p 5432 -c "CREATE DATABASE bareos OWNER bareos;"
sudo -u postgres psql -c "ALTER USER bareos WITH PASSWORD 'yourpassword';"
sudo -u bareos psql -c "ALTER USER bareos WITH PASSWORD 'yourpassword';"
- CHECK ENCODING AGAIN
sudo -u postgres psql -d bareos -c "SHOW server_encoding;"
server_encoding
-----------------
SQL_ASCII
(1 row)
- IMPORT THE ADJUSTED DATABASE:
sudo -u postgres psql -d bareos -f /your-path/bareos.sql
- UPDATE THE DATABASE:
sudo -u postgres /usr/lib/bareos/scripts/update_bareos_tables
- STOP THE OLD DATABASE AND START THE NEW DATABASE:
sudo systemctl stop postgresql
sudo pg_ctlcluster 12 main stop
sudo pg_ctlcluster 16 main stop
If problems arise, delete the new database and start again from the beginning:
sudo pg_dropcluster 16 main –stop
- START THE NEW DATABASE:
sudo pg_ctlcluster 16 main start