0

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?

1 Answer 1

3

From the pgdump docs:

-F format
--format=format
Selects the format of the output. format can be one of the following:

p
plain
Output a plain-text SQL script file (the default).

So the default output format for pg_dump is a plain-text SQL file (which it appears you expect because you call the output dump.sql)

Now from the docs for pg_restore

pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats.

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 use psql (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 use psql?

Sign up to request clarification or add additional context in comments.

1 Comment

I upvoted, would irl suggest always taking full dumps in archive format. You can not filter which objects to restore when using plain text dumps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.