Cannot restore dump backup file for Postgres using pg_restore

I created a backup dump file for my Postgres 9.3.4 using this:

pg_dump table_name -U myusername -h localhost -O > backup.dump 

Now I am trying to back up the old database using:

 pg_restore -U myusername -n public -d table_name backup.dump 

But I keep getting this error:

 pg_restore: [archiver] input file appears to be a text format dump. Please use psql. 

Please note that the file is not a simple sql file, since I generated it using pg_dump.

I used the following command:

 psql perchwell -U myusername -f backup.dump -v ON_ERROR_STOP=1 

and start getting the following error:

 SET SET SET SET SET SET psql:backup.dump:16: ERROR: schema "propertydir" already exists 
+6
source share
2 answers

The default output format pg_dump is actually plaintext sql script. So use psql to import or update using the -Fc flag.

+8
source

Your error: pg_restore: the input file [archiver] is a dump of the text format. Use psql

The error indicates the use of the psql command to import the database.

 cat your-dump-pg-file.dump | psql -d your-database 

This way you can easily restore the file.

In addition, if you install the UTF-8 character set, it will also be better to import.

-1
source

Source: https://habr.com/ru/post/985132/


All Articles