pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists"
2+ messages / 2 participants
[nested] [flat]

* BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists"
@ 2018-10-29 20:37 PG Bug reporting form <noreply@postgresql.org>
  2018-11-08 00:54 ` Re: BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists" Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-10-29 20:37 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: zam6ak@gmail.com

The following bug has been logged on the website:

Bug reference:      15466
Logged by:          zam6ak
Email address:      zam6ak@gmail.com
PostgreSQL version: 11.0
Operating system:   Windows 10
Description:        

When trying to restore logical backups taken on PostgreSQL v10.x (v10
pg_dump, either using custom file format or directory) on PostgreSQL v11
(v11 pg_restore), following error occurs:


-----
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3; 2615 2200 SCHEMA public
postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public"
already exists
    Command was: CREATE SCHEMA public;
-----

How to reproduce (same machine, 2 PG clusters, v10 running on port 5432, v11
running on port 5434, Windows CMD shell)

1) Backup on v10

set PGCLIENTENCODING=UTF8
set PGUSER=postgres
set PGPASSWORD=INeverTell
set PGHOST=localhost
set PGDATABASE=dvdrental

set PGPORT=5432
"I:\PostgreSQL\10\bin\pg_dump.exe" --no-password --no-owner --format custom
--file "I:\Backups\%PGDATABASE%.bak"


2) On v11, create blank DB and attempt to restore into it

set PGPORT=5434
"I:\PostgreSQL\11\bin\psql.exe" -d template1 -c "CREATE DATABASE
%PGDATABASE% WITH ENCODING='UTF8';"
"I:\PostgreSQL\11\bin\pg_restore.exe" --dbname %PGDATABASE% --jobs 4
--no-owner --no-acl  --exit-on-error "I:\Backups\%PGDATABASE%.bak"

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3; 2615 2200 SCHEMA public
postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public"
already exists
    Command was: CREATE SCHEMA public;



WORKAROUNDS:

1) Use pg_restore to produce TOC listing, edit it and comment out CREATE
SCHEMA entry (for public schema only!), then use it with v11 pg_restore 	
	a) "I:\PostgreSQL\11\bin\pg_restore.exe" --list --file
"I:\Backups\%PGDATABASE%.toc.txt" "I:\Backups\%PGDATABASE%.bak"
	b) edit the TOC file and comment out line (1st number may be different):
"3; 2615 2200 SCHEMA - public postgres"
	c) "I:\PostgreSQL\11\bin\pg_restore.exe" --dbname %PGDATABASE% --use-list
"I:\Backups\%PGDATABASE%_toc.txt" --jobs 4 --no-owner --no-acl 
--exit-on-error "I:\Backups\%PGDATABASE%.bak"

2) use v11 pg_backup binary to create a backup on v10 server and then
restore with v11 pg_restore
   FYI, is not always feasible (not at all for us) as customer backups are
being produced automatically (overnight) on remote systems.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists"
  2018-10-29 20:37 BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists" PG Bug reporting form <noreply@postgresql.org>
@ 2018-11-08 00:54 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-11-08 00:54 UTC (permalink / raw)
  To: zam6ak@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> When trying to restore logical backups taken on PostgreSQL v10.x (v10
> pg_dump, either using custom file format or directory) on PostgreSQL v11
> (v11 pg_restore), following error occurs:
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 3; 2615 2200 SCHEMA public
> postgres
> pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public"
> already exists
>     Command was: CREATE SCHEMA public;

Yeah, this is a side effect of some intentional changes to the way that
the public schema is backed up.  v10 used to include the public schema
in the dump, and then pg_restore had some very ugly (and buggy) hacks
to skip that dump item.  v11 doesn't do it like that anymore.  We got
rid of the bugs, but the price is that if you want to restore a pre-v11
dump file using v11 pg_restore, you can't use --exit-on-error.

(It's not that unusual for similar situations to occur with cross-version
dump-restore situations.  I don't know if we'll ever get to a situation
where --exit-on-error can be counted on to never complain; but there is
a reason why it's not the default behavior.)

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-11-08 00:54 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-29 20:37 BUG #15466: Logical backups from v10 cannot be restored with v11 - "ERROR: schema "public" already exists" PG Bug reporting form <noreply@postgresql.org>
2018-11-08 00:54 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox