0

I generated successfully pg dump with directory format and when I restore it restores to DB with the same name as dump was created for despite the fact of me specifying to use alternative name. Here is my pg_dump command & pg_dump -Fd -v -j 2 -Z0 --host=$pghost --username=$username --dbname=postgres --exclude-table=cron.job --exclude-table=cron.job_run_details -f $filename And here is my pg_restore command

pg_restore -Fd -C -j 4 --schema=public --no-owner --verbose --host=$pghost --username=$username --dbname=restore $filename

In this case regardless of me putting --dbname=restore it still restores as postgres

Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66
  • 2
    1) You should not be using the `postgres` database as a user modified database. 2) On the restore don't use the `-C`. Per docs [pg_restore](https://www.postgresql.org/docs/current/app-pgrestore.html): *-C ... 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.*. – Adrian Klaver Feb 11 '23 at 16:59
  • Yes, `-C` was causing it. You can add it as an answer and I accept it. I know about use of `postgres` issue but app was designed this way. – Gregory Suvalian Feb 11 '23 at 22:05

0 Answers0