2

I have to create a postgresql database back up(only the schema) in Linux and restore it on a window machine. I backed up the database with option -E, but I was not able to restore it on the window machine.

Here is the command that I used to backup the database

pg_dump -s -E SQL_ASCII books > books.backup

below is the error message that I received when I tried to restore it.

C:/Program Files/PostgreSQL/9.3/bin\pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname "books" --role "sa" --no-password  --list "C:\progress_db\test1"
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

Am I supposed to use a different command or am I missing something? Your help is greatly appreciated.

4
  • 3
    Did you read the error message? "input file appears to be a text format dump. Please use psql" Commented May 21, 2014 at 20:16
  • I did read the error message. It was the main reason why I used the option -E SQL_ASCII, so that it does not create a text format file. Commented May 21, 2014 at 20:21
  • 1
    -E sets the character encoding, it has nothing to do with the format. Look for -F. postgresql.org/docs/9.3/interactive/app-pgdump.html Anyway, you 'd normally prefer to do the text dump. Commented May 21, 2014 at 20:22
  • Thanks, I think it's my understanding of the option E that is creating the confusion for me. Commented May 21, 2014 at 20:31

1 Answer 1

2

The first lines in the official docs about restoring say:

The text files created by pg_dump are intended to be read in by the psql program. The general command form to restore a dump is

psql dbname < infile

where infile is the file output by the pg_dump command

Or simply read the error message.

The option -E SQL_ASCII only sets the character encoding, it has nothing to do with the format of the dump. By default, pg_dump generates a text file that contains the SQL statements to regenerate the database; in this case, to restore the database you only need to execute the sql commands in the file, as in a psql terminal - that's why a simple psql dbname < mydump is the way to go.

pg_restore is to be used with the alternative "binary" -postgresql specific- format of pg_dump.

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

Comments

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.