0

I have a small subset of our db as a dump to do integration testing. I restore it using this command:

pg_restore --no-acl --no-owner --verbose --create -h localhost -p 5435 -j 4 -U $PG_USER -d test latest.dump

The problem is that in the logs I see:

pg_restore: connecting to database for restore
pg_restore: processing item 5308 ENCODING ENCODING
pg_restore: processing item 5309 STDSTRINGS STDSTRINGS
pg_restore: processing item 5310 DATABASE dlq8aimf0q2pf
pg_restore: creating DATABASE dlq8aimf0q2pf
pg_restore: connecting to new database "dlq8aimf0q2pf"
pg_restore: connecting to database "dlq8aimf0q2pf" as user "postgres"

As you could see it tries to create "dlq8aimf0q2pf" not "test" as I specified. Would I be able to get the database name? What ENV var is using this name?

user3384741
  • 1,261
  • 3
  • 16
  • 21

1 Answers1

0

As said in pg_restore doc about the --create option :

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.

If you have an existing database test and want to restore into it, don't use --create.

Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156