I ran the following commands to create the dump file
sudo docker-compose up -d db
sudo docker exec –i container_name pg_dump –username username database_name > desired_path/dump.sql
And then I added the file to an existing volume in the docker-compose.override.yml
file
version: '3.7'
services:
db:
container_name: seqdb-db-container
volumes:
- ./dump.sql:path_to_volume_used_by_container
ports:
- 5432:5432
Finally I run
sudo docker exec –i container_name psql –username username database_name < path_to_dump_file
and I get the following error:
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
I want to use docker exec pg_restore
without installing psql
. Is there a solution to this or did I mount my volume incorrectly?
From the pgdump docs:
So the default output format for
pg_dump
is a plain-text SQL file (which it appears you expect because you call the outputdump.sql
)Now from the docs for pg_restore
So the error,
input file appears to be a text format dump. Please use psql
, should be expected based on your actions.pg_restore
does not support restoring plain-text dumps - to restore those you should usepsql
(as per the error).The quick solution is to request a non-plain-text format when using
pg_dump
(e.g.--format=custom
). However I am a little confused by your reluctance to usepsql
?