pg_restore --clean --create reference documentation incongruity

From: Matteo Fabbri <ma(dot)fabbri(at)teamsystem(dot)com>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Cc: Matteo Fabbri <matteo(dot)fabbri(at)eutelia(dot)com>
Subject: pg_restore --clean --create reference documentation incongruity
Date: 2016-10-07 09:32:19
Message-ID: 16C69B44-19B0-45E3-B537-FDF85668559F@teamsystem.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,
I'm trying to restore a backup (of TEST2 db) into TEST1 db with the pg_restore options --clean –create.
This is the command launched:

pg_restore -v -h localhost -p 54321 -U postgres -d TEST1 -c -C -F c /Users/matt/Desktop/TEST2.backup

and this is the output:

pg_restore: connecting to database for restore
pg_restore: dropping DATABASE TEST2
pg_restore: creating DATABASE TEST2
pg_restore: connecting to new database "TEST2"
pg_restore: connecting to database "TEST2" as user "postgres"
pg_restore: creating SCHEMA public
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 7; 2615 2200 SCHEMA public postgres
pg_restore: [archiver (db)] could not execute query: ERROR: schema "public" already exists
Command was: CREATE SCHEMA public;

pg_restore: creating COMMENT SCHEMA public
pg_restore: creating SCHEMA schemax
pg_restore: creating EXTENSION plpgsql
pg_restore: creating COMMENT EXTENSION plpgsql
pg_restore: creating TABLE table_1
pg_restore: processing data for table "table_1"
pg_restore: creating CONSTRAINT table_1_pkey
pg_restore: setting owner and privileges for DATABASE TEST2
pg_restore: setting owner and privileges for SCHEMA public
pg_restore: setting owner and privileges for COMMENT SCHEMA public
pg_restore: setting owner and privileges for ACL public
pg_restore: setting owner and privileges for SCHEMA schemax
pg_restore: setting owner and privileges for EXTENSION plpgsql
pg_restore: setting owner and privileges for COMMENT EXTENSION plpgsql
pg_restore: setting owner and privileges for TABLE table_1
pg_restore: setting owner and privileges for TABLE DATA table_1
pg_restore: setting owner and privileges for CONSTRAINT table_1_pkey
WARNING: errors ignored on restore: 1

Now, now as described in the reference documentation

-C
--create
Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it.
When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is restored into the database name that appears in the archive.
I expected the specified db (-d TEST1) was dropped and created, not the TEST2 db.
In essence it seems that the –d parameter is ignored and TEST1 db remains untouched.
What is the correct behavior? Is a pg_restore error? Is a reference documentation error? Or simply I have not interpreted correctly it?
Thanks in advance,
matt

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Poul Kristensen 2016-10-07 12:11:41 Infrastructure
Previous Message Lazaro Garcia 2016-10-06 22:53:00 Pruebas de carga PostgreSQL vs SQLServer