简体   繁体   中英

Can't restore a dump backup file for Postgres using pg_restore

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

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

Now I'm trying to backup 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 plain sql file since I generated it using pg_dump.

I used the follwoing command:

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

and start receiving the following error:

SET
SET
SET
SET
SET
SET
psql:backup.dump:16: ERROR:  schema "propertydir" already exists

The default output format of pg_dump is actually plaintext sql script. So use psql for import or redump with the -Fc flag.

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

Bug indicate use psql command to import database.

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

This way, you can easily restore file

In additionally if you set character set UTF-8, will make better import too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM