1

My situation is a little bit complicated.

I have an older version of PostgreSQL 12.9 installed on an older Centos Stream 8 machine. There are about five custom databases created under the roof, say database1, ozssc, database5, owned by different roles to handle different business applications.

As our business application has been updated recently, we plan to update the database as well.

There is another newer machine, CentOS Stream 9 was set up, and PostgreSQL 15.2 was installed on the newer machine.

First, we tried to dump all database schema and data by using the newer version (15.2) command pg_dump from the newer machine:

pg_dump -h 10.0.1.105 -p 5433  -U postgres -v -n '*' -N 'pg_toast' -N 'information_schema' -N 'pg_catalog' $DB -Ft -f ${bkp_path}/${DB}_schema_bkp_${date}.tar

Which will dump 5 XXX.tar files

Then I tried to restore it (by using the same version (15.2) of pg_restore) to my newer machine (Centos Stream 9)

pg_restore -h 10.0.1.103 -p 5433 -U postgres -w -d $db_name $db_tar_file

Run those commands, system response error as:

pg_restore: error: could not execute query: ERROR:  unacceptable schema name "pg_temp_1"
DETAIL:  The prefix "pg_" is reserved for system schemas.
Command was: CREATE SCHEMA pg_temp_1;

As result, there quite lot of database setting is incorrect as well:

pg_restore could not set the correct database owner from the dumped sql statement. For example the SQL statement in database ozssc as:

CREATE DATABASE ozssc WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_AU.UTF-8';
ALTER DATABASE ozssc OWNER TO tomcat;

Those statement will change database ozssc owner to tomcat.

After restoration, I check the database ozssc's owner; it is still PostgreSQL instead of tomcat.

Another significant error is that it seems pg_dump does not dump any extensions. For example, there are about other three extensions, such as cutest, cube, and earth distance in the original database ozssc, but I don't find anything in dumped sql statement.

As this operation (pg_dump/restore) failed, I tried to look for pg_upgrade, but unfortunately. I found pg_upgrade only support some host upgrade by different installed directory.

Could anyone advise: How we can use pg_upgrade to migrate PostgreSQL 12 to 15 over the network instead of on the same host?

3
  • Why did you run pg_dump against a 12.9 database? I suggest installing 12.9 on the newer machine, importing the database, then performing the upgrade to 15.2. I am not sure I understand, what you mean by "migrating 12.9 to 15.2 over the network".
    – Ramhound
    Commented Mar 1, 2023 at 0:15
  • "Over the network" means, postgresql 12.9 and postgresql 15.2 runs on different hosts. They are seating in same subnet.
    – cidy.long
    Commented Mar 1, 2023 at 3:17
  • 1
    This may be a better fit for dba.stackexchange.com. Thats said, why don't you exclude "pg_temp_1" from your dump - ie with another -N 'pg_temp_1' ?
    – davidgo
    Commented Mar 1, 2023 at 4:09

0

You must log in to answer this question.

Browse other questions tagged .