Search code examples
postgresqlpg-restore

pg_restore: error: options -d/--dbname and -f/--file cannot be used together


I'm somewhat new to postgres and having trouble with restoring a local database with backup data using pg_restore and hoping to get some help. My situation is as follows:

  • I have postgres running on Docker and I can access pgadmin.
  • I have created a new server in pgadmin called 'flocal' with host name postgres_db user name postgres and port 5432.
  • In this new server, I have created a new database called fdb
  • I have a backup folder called fprod on my local PC (mac if it matters) that contains a bunch of .dat.gz files inside.

Now I navigate to this backup folder and in my local terminal I run this:

pg_restore -h postgres_db -p 5432 -U postgres -d fdb -f fprod

And I get the following error message below. I've tried changing my hostname to just -h localhost but no difference.

pg_restore: error: options -d/--dbname and -f/--file cannot be used together

What am I missing and doing wrong? Please advise.


Solution

  • As documented in the manual -f does not specify the input file, it specifies an output file e.g. for the --list command.

    So you need:

    pg_restore -h postgres_db -p 5432 -U postgres -d fdb fprod