I am trying to execute the following command to restore db in a Docker container:
cmd /c "docker exec -i database-container pg_restore -C -U postgres -d employee -v < C:\\backup\\employee.tar"
But it throws: "pg_restore: error: connection to database "employee" failed: FATAL: database "employee" does not exist" (If I create an empty database with the same name, it is created without any problem).
The reason may be:
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.
So, is it possible to restore db using the same pg_restore command? Or should I modify it by adding drop and create commands to fix the problem?
cmd /c "docker exec database-container pg_restore --username=postgres --no-password --dbname=employee --verbose C:\backup\employee.tar"but not worked.