簡體   English   中英

無法使用pg_restore為Postgres恢復轉儲備份文件

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

我使用這個為Postgres 9.3.4生成了一個轉儲備份文件:

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

現在我正在嘗試使用以下方法備份舊數據庫:

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

但我一直收到這個錯誤:

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

請注意,該文件不是普通的sql文件,因為我使用pg_dump生成它。

我使用了以下命令:

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

並開始收到以下錯誤:

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

pg_dump的默認輸出格式實際上是純文本sql腳本。 因此,使用psql進行導入或使用-Fc標志進行redump。

您的錯誤:pg_restore:[archiver]輸入文件似乎是文本格式轉儲。 請使用psql

錯誤表明使用psql命令導入數據庫。

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

這樣,您就可以輕松恢復文件

另外如果你設置字符集UTF-8,也會更好地導入。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM