[英]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: 我使用这个为Postgres 9.3.4生成了一个转储备份文件:
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. 请注意,该文件不是普通的sql文件,因为我使用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. pg_dump的默认输出格式实际上是纯文本sql脚本。 So use psql for import or redump with the -Fc
flag. 因此,使用psql进行导入或使用-Fc
标志进行redump。
Your bug: pg_restore: [archiver] input file appears to be a text format dump. 您的错误:pg_restore:[archiver]输入文件似乎是文本格式转储。 Please use psql 请使用psql
Bug indicate use psql command to import database. 错误表明使用psql命令导入数据库。
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. 另外如果你设置字符集UTF-8,也会更好地导入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.